Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
59b16fa9
You need to sign in or sign up before continuing.
Commit
59b16fa9
authored
Feb 26, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
maxout/prelu
parent
0d894877
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
example_mnist.py
example_mnist.py
+2
-2
tensorpack/models/model_desc.py
tensorpack/models/model_desc.py
+1
-1
tensorpack/models/nonl.py
tensorpack/models/nonl.py
+24
-0
No files found.
example_mnist.py
View file @
59b16fa9
...
@@ -21,7 +21,7 @@ from tensorpack.dataflow import *
...
@@ -21,7 +21,7 @@ from tensorpack.dataflow import *
"""
"""
MNIST ConvNet example.
MNIST ConvNet example.
99.25
%
validation accuracy
after 50 epochs.
about 0.55
%
validation error
after 50 epochs.
"""
"""
BATCH_SIZE
=
128
BATCH_SIZE
=
128
...
@@ -40,7 +40,7 @@ class Model(ModelDesc):
...
@@ -40,7 +40,7 @@ class Model(ModelDesc):
image
,
label
=
input_vars
image
,
label
=
input_vars
image
=
tf
.
expand_dims
(
image
,
3
)
# add a single channel
image
=
tf
.
expand_dims
(
image
,
3
)
# add a single channel
nl
=
tf
.
nn
.
relu
nl
=
p
relu
image
=
image
*
2
-
1
image
=
image
*
2
-
1
l
=
Conv2D
(
'conv0'
,
image
,
out_channel
=
32
,
kernel_shape
=
3
,
nl
=
nl
,
l
=
Conv2D
(
'conv0'
,
image
,
out_channel
=
32
,
kernel_shape
=
3
,
nl
=
nl
,
padding
=
'VALID'
)
padding
=
'VALID'
)
...
...
tensorpack/models/model_desc.py
View file @
59b16fa9
...
@@ -72,4 +72,4 @@ class ModelDesc(object):
...
@@ -72,4 +72,4 @@ class ModelDesc(object):
def
get_gradient_processor
(
self
):
def
get_gradient_processor
(
self
):
""" Return a list of GradientProcessor. They will be executed in order"""
""" Return a list of GradientProcessor. They will be executed in order"""
return
[
SummaryGradient
(),
Check
Gradient
()]
return
[
CheckGradient
(),
Summary
Gradient
()]
tensorpack/models/nonl.py
0 → 100644
View file @
59b16fa9
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
# File: nonl.py
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
import
tensorflow
as
tf
from
copy
import
copy
from
._common
import
*
__all__
=
[
'Maxout'
,
'prelu'
]
@
layer_register
()
def
Maxout
(
x
,
num_unit
):
input_shape
=
x
.
get_shape
()
.
as_list
()
assert
len
(
input_shape
)
==
4
ch
=
input_shape
[
3
]
assert
ch
%
num_unit
==
0
x
=
tf
.
reshape
(
x
,
[
-
1
,
input_shape
[
1
],
input_shape
[
2
],
ch
/
3
,
3
])
return
tf
.
reduce_max
(
x
,
4
,
name
=
'output'
)
def
PReLU
(
x
,
init
=
tf
.
constant_initializer
(
0.001
)):
alpha
=
tf
.
get_variable
(
'alpha'
,
[],
initializer
=
init
)
return
((
1
+
alpha
)
*
x
+
(
1
-
alpha
)
*
tf
.
abs
(
x
))
*
0.5
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment