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
4185a222
Commit
4185a222
authored
Dec 30, 2015
by
ppwwyyxx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix some errors
parent
09e99778
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
5 deletions
+10
-5
tensorpack/models/conv2d.py
tensorpack/models/conv2d.py
+1
-1
tensorpack/models/fc.py
tensorpack/models/fc.py
+1
-1
tensorpack/train.py
tensorpack/train.py
+3
-1
tensorpack/utils/concurrency.py
tensorpack/utils/concurrency.py
+4
-2
tensorpack/utils/sessinit.py
tensorpack/utils/sessinit.py
+1
-0
usercustomize.py
usercustomize.py
+0
-0
No files found.
tensorpack/models/conv2d.py
View file @
4185a222
...
@@ -35,7 +35,7 @@ def Conv2D(x, out_channel, kernel_shape,
...
@@ -35,7 +35,7 @@ def Conv2D(x, out_channel, kernel_shape,
if
b_init
is
None
:
if
b_init
is
None
:
b_init
=
tf
.
constant_initializer
()
b_init
=
tf
.
constant_initializer
()
W
=
tf
.
get_variable
(
'W'
,
filter_shape
,
initializer
=
W_init
)
# TODO collections
W
=
tf
.
get_variable
(
'W'
,
filter_shape
,
initializer
=
W_init
)
b
=
tf
.
get_variable
(
'b'
,
[
out_channel
],
initializer
=
b_init
)
b
=
tf
.
get_variable
(
'b'
,
[
out_channel
],
initializer
=
b_init
)
if
split
==
1
:
if
split
==
1
:
...
...
tensorpack/models/fc.py
View file @
4185a222
...
@@ -23,4 +23,4 @@ def FullyConnected(x, out_dim, W_init=None, b_init=None, nl=tf.nn.relu):
...
@@ -23,4 +23,4 @@ def FullyConnected(x, out_dim, W_init=None, b_init=None, nl=tf.nn.relu):
W
=
tf
.
get_variable
(
'W'
,
[
in_dim
,
out_dim
],
initializer
=
W_init
)
W
=
tf
.
get_variable
(
'W'
,
[
in_dim
,
out_dim
],
initializer
=
W_init
)
b
=
tf
.
get_variable
(
'b'
,
[
out_dim
],
initializer
=
b_init
)
b
=
tf
.
get_variable
(
'b'
,
[
out_dim
],
initializer
=
b_init
)
return
nl
(
tf
.
matmul
(
x
,
W
)
+
b
)
return
nl
(
tf
.
matmul
(
x
,
W
)
+
b
,
name
=
tf
.
get_variable_scope
()
.
name
+
'_output'
)
tensorpack/train.py
View file @
4185a222
...
@@ -87,7 +87,7 @@ def start_train(config):
...
@@ -87,7 +87,7 @@ def start_train(config):
# start training:
# start training:
coord
=
tf
.
train
.
Coordinator
()
coord
=
tf
.
train
.
Coordinator
()
# a thread that keeps filling the queue
# a thread that keeps filling the queue
input_th
=
EnqueueThread
(
sess
,
coord
,
enqueue_op
,
dataset
)
input_th
=
EnqueueThread
(
sess
,
coord
,
enqueue_op
,
dataset
,
input_queue
)
model_th
=
tf
.
train
.
start_queue_runners
(
model_th
=
tf
.
train
.
start_queue_runners
(
sess
=
sess
,
coord
=
coord
,
daemon
=
True
,
start
=
True
)
sess
=
sess
,
coord
=
coord
,
daemon
=
True
,
start
=
True
)
input_th
.
start
()
input_th
.
start
()
...
@@ -101,7 +101,9 @@ def start_train(config):
...
@@ -101,7 +101,9 @@ def start_train(config):
if
coord
.
should_stop
():
if
coord
.
should_stop
():
return
return
fetches
=
[
train_op
,
cost_var
]
+
output_vars
+
model_inputs
fetches
=
[
train_op
,
cost_var
]
+
output_vars
+
model_inputs
print
'before'
results
=
sess
.
run
(
fetches
)
results
=
sess
.
run
(
fetches
)
print
'after'
cost
=
results
[
1
]
cost
=
results
[
1
]
outputs
=
results
[
2
:
2
+
len
(
output_vars
)]
outputs
=
results
[
2
:
2
+
len
(
output_vars
)]
inputs
=
results
[
-
len
(
model_inputs
):]
inputs
=
results
[
-
len
(
model_inputs
):]
...
...
tensorpack/utils/concurrency.py
View file @
4185a222
...
@@ -25,13 +25,15 @@ class StoppableThread(threading.Thread):
...
@@ -25,13 +25,15 @@ class StoppableThread(threading.Thread):
class
EnqueueThread
(
threading
.
Thread
):
class
EnqueueThread
(
threading
.
Thread
):
def
__init__
(
self
,
sess
,
coord
,
enqueue_op
,
dataflow
):
def
__init__
(
self
,
sess
,
coord
,
enqueue_op
,
dataflow
,
queue
):
super
(
EnqueueThread
,
self
)
.
__init__
()
super
(
EnqueueThread
,
self
)
.
__init__
()
self
.
sess
=
sess
self
.
sess
=
sess
self
.
coord
=
coord
self
.
coord
=
coord
self
.
input_vars
=
sess
.
graph
.
get_collection
(
INPUT_VARS_KEY
)
self
.
input_vars
=
sess
.
graph
.
get_collection
(
INPUT_VARS_KEY
)
self
.
dataflow
=
dataflow
self
.
dataflow
=
dataflow
self
.
op
=
enqueue_op
self
.
op
=
enqueue_op
self
.
queue
=
queue
self
.
daemon
=
True
self
.
daemon
=
True
def
run
(
self
):
def
run
(
self
):
...
@@ -45,8 +47,8 @@ class EnqueueThread(threading.Thread):
...
@@ -45,8 +47,8 @@ class EnqueueThread(threading.Thread):
except
tf
.
errors
.
CancelledError
as
e
:
except
tf
.
errors
.
CancelledError
as
e
:
pass
pass
except
Exception
:
except
Exception
:
# TODO close queue.
logger
.
exception
(
"Exception in EnqueueThread:"
)
logger
.
exception
(
"Exception in EnqueueThread:"
)
self
.
queue
.
close
(
cancel_pending_enqueues
=
True
)
self
.
coord
.
request_stop
()
self
.
coord
.
request_stop
()
@
contextmanager
@
contextmanager
...
...
tensorpack/utils/sessinit.py
View file @
4185a222
...
@@ -35,6 +35,7 @@ class ParamRestore(SessionInit):
...
@@ -35,6 +35,7 @@ class ParamRestore(SessionInit):
self
.
prms
=
param_dict
self
.
prms
=
param_dict
def
init
(
self
,
sess
):
def
init
(
self
,
sess
):
sess
.
run
(
tf
.
initialize_all_variables
())
variables
=
tf
.
get_collection
(
tf
.
GraphKeys
.
TRAINABLE_VARIABLES
)
variables
=
tf
.
get_collection
(
tf
.
GraphKeys
.
TRAINABLE_VARIABLES
)
var_dict
=
dict
([
v
.
name
,
v
]
for
v
in
variables
)
var_dict
=
dict
([
v
.
name
,
v
]
for
v
in
variables
)
for
name
,
value
in
self
.
prms
.
iteritems
():
for
name
,
value
in
self
.
prms
.
iteritems
():
...
...
tensorpack/
usercustomize.py
→
usercustomize.py
View file @
4185a222
File moved
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