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
bcd0ce6d
You need to sign in or sign up before continuing.
Commit
bcd0ce6d
authored
Dec 25, 2015
by
ppwwyyxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convnet
parent
83686e04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
19 deletions
+19
-19
example_mnist.py
example_mnist.py
+19
-8
utils/utils.py
utils/utils.py
+0
-11
No files found.
example_mnist.py
View file @
bcd0ce6d
...
@@ -3,6 +3,12 @@
...
@@ -3,6 +3,12 @@
# File: example_mnist.py
# File: example_mnist.py
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
# HACK protobuf
#import sys
#import os
#sys.path.insert(0, os.path.expanduser('~/.local/lib/python2.7/site-packages'))
import
tensorflow
as
tf
import
tensorflow
as
tf
import
numpy
as
np
import
numpy
as
np
from
itertools
import
count
from
itertools
import
count
...
@@ -28,15 +34,20 @@ def get_model(input, label):
...
@@ -28,15 +34,20 @@ def get_model(input, label):
output: variable
output: variable
cost: scalar variable
cost: scalar variable
"""
"""
input
=
tf
.
reshape
(
input
,
[
-
1
,
28
,
28
,
1
])
input
=
tf
.
reshape
(
input
,
[
-
1
,
IMAGE_SIZE
,
IMAGE_SIZE
,
1
])
conv
=
Conv2D
(
'conv0'
,
input
,
out_channel
=
20
,
kernel_shape
=
3
,
conv0
=
Conv2D
(
'conv0'
,
input
,
out_channel
=
5
,
kernel_shape
=
3
,
padding
=
'same'
)
padding
=
'valid'
)
input
=
tf
.
reshape
(
input
,
[
-
1
,
28
*
28
])
pool0
=
tf
.
nn
.
max_pool
(
conv0
,
ksize
=
[
1
,
2
,
2
,
1
],
strides
=
[
1
,
2
,
2
,
1
],
padding
=
'SAME'
)
fc0
=
FullyConnected
(
'fc0'
,
input
,
200
)
conv1
=
Conv2D
(
'conv1'
,
pool0
,
out_channel
=
10
,
kernel_shape
=
4
,
padding
=
'valid'
)
pool1
=
tf
.
nn
.
max_pool
(
conv1
,
ksize
=
[
1
,
2
,
2
,
1
],
strides
=
[
1
,
2
,
2
,
1
],
padding
=
'SAME'
)
feature
=
batch_flatten
(
pool1
)
fc0
=
FullyConnected
(
'fc0'
,
feature
,
512
)
fc0
=
tf
.
nn
.
relu
(
fc0
)
fc0
=
tf
.
nn
.
relu
(
fc0
)
fc1
=
FullyConnected
(
'fc1'
,
fc0
,
out_dim
=
200
)
fc1
=
tf
.
nn
.
relu
(
fc1
)
fc2
=
FullyConnected
(
'lr'
,
fc1
,
out_dim
=
10
)
fc2
=
FullyConnected
(
'lr'
,
fc1
,
out_dim
=
10
)
prob
=
tf
.
nn
.
softmax
(
fc2
,
name
=
'output'
)
prob
=
tf
.
nn
.
softmax
(
fc2
,
name
=
'output'
)
...
...
utils/utils.py
View file @
bcd0ce6d
...
@@ -5,14 +5,3 @@
...
@@ -5,14 +5,3 @@
import
tensorflow
as
tf
import
tensorflow
as
tf
__all__
=
[
'one_hot'
]
def
one_hot
(
y
,
num_labels
):
batch_size
=
tf
.
size
(
y
)
y
=
tf
.
expand_dims
(
y
,
1
)
indices
=
tf
.
expand_dims
(
tf
.
range
(
0
,
batch_size
),
1
)
concated
=
tf
.
concat
(
1
,
[
indices
,
y
])
onehot_labels
=
tf
.
sparse_to_dense
(
concated
,
tf
.
pack
([
batch_size
,
num_labels
]),
1.0
,
0.0
)
onehot_labels
.
set_shape
([
None
,
num_labels
])
return
tf
.
cast
(
onehot_labels
,
tf
.
float32
)
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