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
132dcccd
You need to sign in or sign up before continuing.
Commit
132dcccd
authored
Jun 17, 2016
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle disk error
parent
ecc33298
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
29 deletions
+44
-29
examples/char-rnn/README.md
examples/char-rnn/README.md
+2
-0
tensorpack/callbacks/common.py
tensorpack/callbacks/common.py
+8
-5
tensorpack/callbacks/summary.py
tensorpack/callbacks/summary.py
+6
-3
tensorpack/train/trainer.py
tensorpack/train/trainer.py
+4
-1
tensorpack/utils/stat.py
tensorpack/utils/stat.py
+24
-20
No files found.
examples/char-rnn/README.md
View file @
132dcccd
...
...
@@ -115,3 +115,5 @@ weston, improving neural grammatical model flow images is allows belief networks
generating neural networks, there is not the initial particular marked pseudo-cameral rnns
sophett, pattern wlth designs for faster than the inference in deep learning. in nips (most),
```
See
[
blog of Andrej Karpathy
](
http://karpathy.github.io/2015/05/21/rnn-effectiveness/
)
for more interesting stories on this topic.
tensorpack/callbacks/common.py
View file @
132dcccd
...
...
@@ -49,11 +49,14 @@ class ModelSaver(Callback):
return
var_dict
def
_trigger_epoch
(
self
):
self
.
saver
.
save
(
tf
.
get_default_session
(),
self
.
path
,
global_step
=
self
.
global_step
,
write_meta_graph
=
not
self
.
meta_graph_written
)
try
:
self
.
saver
.
save
(
tf
.
get_default_session
(),
self
.
path
,
global_step
=
self
.
global_step
,
write_meta_graph
=
not
self
.
meta_graph_written
)
except
Exception
:
# disk error sometimes..
logger
.
exception
(
"Exception in ModelSaver.trigger_epoch!"
)
if
not
self
.
meta_graph_written
:
self
.
meta_graph_written
=
True
...
...
tensorpack/callbacks/summary.py
View file @
132dcccd
...
...
@@ -69,9 +69,12 @@ class StatHolder(object):
def
_write_stat
(
self
):
tmp_filename
=
self
.
filename
+
'.tmp'
with
open
(
tmp_filename
,
'w'
)
as
f
:
json
.
dump
(
self
.
stat_history
,
f
)
os
.
rename
(
tmp_filename
,
self
.
filename
)
try
:
with
open
(
tmp_filename
,
'w'
)
as
f
:
json
.
dump
(
self
.
stat_history
,
f
)
os
.
rename
(
tmp_filename
,
self
.
filename
)
except
IOError
:
# disk error sometimes..
logger
.
exception
(
"Exception in StatHolder.finalize()!"
)
class
StatPrinter
(
Callback
):
"""
...
...
tensorpack/train/trainer.py
View file @
132dcccd
...
...
@@ -91,7 +91,10 @@ class EnqueueThread(threading.Thread):
except
Exception
:
logger
.
exception
(
"Exception in EnqueueThread:"
)
finally
:
self
.
sess
.
run
(
self
.
close_op
)
try
:
self
.
sess
.
run
(
self
.
close_op
)
except
RuntimeError
:
# session already closed
pass
self
.
coord
.
request_stop
()
logger
.
info
(
"Enqueue Thread Exited."
)
...
...
tensorpack/utils/stat.py
View file @
132dcccd
...
...
@@ -3,59 +3,63 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com>
import
numpy
as
np
__all__
=
[
'StatCounter'
,
'Accuracy'
,
'BinaryStatistics'
]
__all__
=
[
'StatCounter'
,
'Accuracy'
,
'BinaryStatistics'
,
'RatioStatistics'
]
class
StatCounter
(
object
):
def
__init__
(
self
):
self
.
reset
()
def
feed
(
self
,
v
):
self
.
values
.
append
(
v
)
self
.
_
values
.
append
(
v
)
def
reset
(
self
):
self
.
values
=
[]
self
.
_
values
=
[]
@
property
def
count
(
self
):
return
len
(
self
.
values
)
return
len
(
self
.
_
values
)
@
property
def
average
(
self
):
assert
len
(
self
.
values
)
return
np
.
mean
(
self
.
values
)
assert
len
(
self
.
_
values
)
return
np
.
mean
(
self
.
_
values
)
@
property
def
sum
(
self
):
assert
len
(
self
.
values
)
return
np
.
sum
(
self
.
values
)
assert
len
(
self
.
_
values
)
return
np
.
sum
(
self
.
_
values
)
@
property
def
max
(
self
):
assert
len
(
self
.
values
)
return
max
(
self
.
values
)
assert
len
(
self
.
_
values
)
return
max
(
self
.
_
values
)
class
Accuracy
(
object
):
class
RatioStatistics
(
object
):
def
__init__
(
self
):
self
.
reset
()
def
reset
(
self
):
self
.
tot
=
0
self
.
corr
=
0
self
.
_
tot
=
0
self
.
_cnt
=
0
def
feed
(
self
,
c
orr
,
tot
=
1
):
self
.
tot
+=
tot
self
.
corr
+=
corr
def
feed
(
self
,
c
nt
,
tot
=
1
):
self
.
_
tot
+=
tot
self
.
_cnt
+=
cnt
@
property
def
accuracy
(
self
):
if
self
.
tot
==
0
:
def
ratio
(
self
):
if
self
.
_
tot
==
0
:
return
0
return
self
.
corr
*
1.0
/
self
.
tot
return
self
.
_cnt
*
1.0
/
self
.
_
tot
@
property
def
count
(
self
):
return
self
.
tot
return
self
.
_
tot
class
Accuracy
(
RatioStatistics
):
@
property
def
accuracy
(
self
):
return
self
.
ratio
class
BinaryStatistics
(
object
):
"""
...
...
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