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
9972b150
Commit
9972b150
authored
Mar 03, 2018
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(fix #685)
parent
760b924a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
21 deletions
+25
-21
examples/Char-RNN/char-rnn.py
examples/Char-RNN/char-rnn.py
+3
-1
tensorpack/callbacks/inference_runner.py
tensorpack/callbacks/inference_runner.py
+2
-0
tensorpack/input_source/input_source.py
tensorpack/input_source/input_source.py
+19
-19
tensorpack/input_source/input_source_base.py
tensorpack/input_source/input_source_base.py
+1
-1
No files found.
examples/Char-RNN/char-rnn.py
View file @
9972b150
...
...
@@ -33,7 +33,7 @@ param.seq_len = 50
param
.
grad_clip
=
5.
param
.
vocab_size
=
None
param
.
softmax_temprature
=
1
param
.
corpus
=
'input.txt'
param
.
corpus
=
None
class
CharRNNData
(
RNGDataFlow
):
...
...
@@ -182,6 +182,7 @@ if __name__ == '__main__':
parser_sample
.
add_argument
(
'-t'
,
'--temperature'
,
type
=
float
,
default
=
1
,
help
=
'softmax temperature'
)
parser_train
=
subparsers
.
add_parser
(
'train'
,
help
=
'train'
)
parser_train
.
add_argument
(
'--corpus'
,
help
=
'corpus file'
,
default
=
'input.txt'
)
args
=
parser
.
parse_args
()
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
...
...
@@ -192,6 +193,7 @@ if __name__ == '__main__':
sample
(
args
.
load
,
args
.
start
,
args
.
num
)
sys
.
exit
()
else
:
param
.
corpus
=
args
.
corpus
config
=
get_config
()
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
...
...
tensorpack/callbacks/inference_runner.py
View file @
9972b150
...
...
@@ -156,6 +156,7 @@ class InferenceRunner(InferenceRunnerBase):
for
inf
in
self
.
infs
:
inf
.
before_epoch
()
self
.
_input_source
.
reset_state
()
# iterate over the data, and run the hooked session
with
_inference_context
(),
\
tqdm
.
tqdm
(
total
=
self
.
_size
,
**
get_tqdm_kwargs
())
as
pbar
:
...
...
@@ -265,6 +266,7 @@ class DataParallelInferenceRunner(InferenceRunnerBase):
total
=
self
.
_size
nr_tower
=
len
(
self
.
_gpus
)
self
.
_input_source
.
reset_state
()
with
_inference_context
():
with
tqdm
.
tqdm
(
total
=
total
,
**
get_tqdm_kwargs
())
as
pbar
:
while
total
>=
nr_tower
:
...
...
tensorpack/input_source/input_source.py
View file @
9972b150
...
...
@@ -196,8 +196,10 @@ class QueueInput(FeedfreeInput):
self
.
_dequeue_op
=
self
.
queue
.
dequeue
(
name
=
'dequeue_for_reset'
)
def
_reset_state
(
self
):
if
self
.
_started
:
# do not try to clear the queue if there is nothing
def
refill_queue
(
self
):
"""
Clear the queue, then call dataflow.get_data() again and fill into the queue.
"""
self
.
thread
.
pause
()
# pause enqueue
opt
=
tf
.
RunOptions
()
...
...
@@ -213,8 +215,6 @@ class QueueInput(FeedfreeInput):
# reset dataflow, start thread
self
.
thread
.
reinitialize_dataflow
()
self
.
thread
.
resume
()
else
:
self
.
_started
=
True
def
_create_ema_callback
(
self
):
"""
...
...
tensorpack/input_source/input_source_base.py
View file @
9972b150
...
...
@@ -137,7 +137,7 @@ class InputSource(object):
Initialize/reinitialize this InputSource.
Must be called under a default session.
For training, it will get called by the trainer in `before_train` callbacks.
For training, it will get called
once
by the trainer in `before_train` callbacks.
For inference, the :class:`InferenceRunner` will call this method each time it is triggered.
"""
self
.
_reset_state
()
...
...
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