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
9ce7f032
Commit
9ce7f032
authored
Nov 09, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use tf.keras rather than keras
parent
627ad534
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
7 deletions
+6
-7
examples/mnist-keras-v2.py
examples/mnist-keras-v2.py
+5
-6
tensorpack/contrib/keras.py
tensorpack/contrib/keras.py
+1
-1
No files found.
examples/mnist-keras-v2.py
View file @
9ce7f032
...
@@ -6,9 +6,8 @@
...
@@ -6,9 +6,8 @@
import
numpy
as
np
import
numpy
as
np
import
tensorflow
as
tf
import
tensorflow
as
tf
from
keras.models
import
Sequential
from
tensorflow
import
keras
import
keras.layers
as
KL
KL
=
keras
.
layers
from
keras
import
regularizers
from
tensorpack.train
import
SimpleTrainer
from
tensorpack.train
import
SimpleTrainer
...
@@ -35,7 +34,7 @@ def get_data():
...
@@ -35,7 +34,7 @@ def get_data():
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
logger
.
auto_set_dir
()
logger
.
auto_set_dir
()
M
=
Sequential
()
M
=
keras
.
models
.
Sequential
()
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
activation
=
'relu'
,
input_shape
=
[
IMAGE_SIZE
,
IMAGE_SIZE
,
1
],
padding
=
'same'
))
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
activation
=
'relu'
,
input_shape
=
[
IMAGE_SIZE
,
IMAGE_SIZE
,
1
],
padding
=
'same'
))
M
.
add
(
KL
.
MaxPooling2D
())
M
.
add
(
KL
.
MaxPooling2D
())
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
activation
=
'relu'
,
padding
=
'same'
))
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
activation
=
'relu'
,
padding
=
'same'
))
...
@@ -43,9 +42,9 @@ if __name__ == '__main__':
...
@@ -43,9 +42,9 @@ if __name__ == '__main__':
M
.
add
(
KL
.
MaxPooling2D
())
M
.
add
(
KL
.
MaxPooling2D
())
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
padding
=
'same'
,
activation
=
'relu'
))
M
.
add
(
KL
.
Conv2D
(
32
,
3
,
padding
=
'same'
,
activation
=
'relu'
))
M
.
add
(
KL
.
Flatten
())
M
.
add
(
KL
.
Flatten
())
M
.
add
(
KL
.
Dense
(
512
,
activation
=
'relu'
,
kernel_regularizer
=
regularizers
.
l2
(
1e-5
)))
M
.
add
(
KL
.
Dense
(
512
,
activation
=
'relu'
,
kernel_regularizer
=
keras
.
regularizers
.
l2
(
1e-5
)))
M
.
add
(
KL
.
Dropout
(
0.5
))
M
.
add
(
KL
.
Dropout
(
0.5
))
M
.
add
(
KL
.
Dense
(
10
,
activation
=
None
,
kernel_regularizer
=
regularizers
.
l2
(
1e-5
)))
M
.
add
(
KL
.
Dense
(
10
,
activation
=
None
,
kernel_regularizer
=
keras
.
regularizers
.
l2
(
1e-5
)))
M
.
add
(
KL
.
Activation
(
'softmax'
))
M
.
add
(
KL
.
Activation
(
'softmax'
))
dataset_train
,
dataset_test
=
get_data
()
dataset_train
,
dataset_test
=
get_data
()
...
...
tensorpack/contrib/keras.py
View file @
9ce7f032
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
import
tensorflow
as
tf
import
tensorflow
as
tf
from
six.moves
import
zip
from
six.moves
import
zip
import
keras
from
tensorflow
import
keras
from
..graph_builder
import
InputDesc
from
..graph_builder
import
InputDesc
from
..tfutils.tower
import
get_current_tower_context
from
..tfutils.tower
import
get_current_tower_context
...
...
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