Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.tensorflow
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
bob
bob.learn.tensorflow
Commits
8082804e
"README.md" did not exist on "f36ad8e65549da7b36175e6526fc6be99eac4045"
Commit
8082804e
authored
5 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
fix imports
parent
27e73aec
No related branches found
No related tags found
1 merge request
!79
Add keras-based models, add pixel-wise loss, other improvements
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/learn/tensorflow/utils/hooks.py
+5
-6
5 additions, 6 deletions
bob/learn/tensorflow/utils/hooks.py
with
5 additions
and
6 deletions
bob/learn/tensorflow/utils/hooks.py
+
5
−
6
View file @
8082804e
...
...
@@ -2,14 +2,13 @@ from datetime import datetime
from
tensorflow.python.training.basic_session_run_hooks
import
_as_graph_element
import
logging
import
numpy
as
np
import
six
import
tensorflow
as
tf
import
time
logger
=
logging
.
getLogger
(
__name__
)
class
TensorSummary
(
tf
.
train
.
SessionRunHook
):
class
TensorSummary
(
tf
.
estimator
.
SessionRunHook
):
"""
Adds the given (scalar) tensors to tensorboard summaries
"""
def
__init__
(
self
,
tensors
,
tensor_names
=
None
,
**
kwargs
):
...
...
@@ -24,7 +23,7 @@ class TensorSummary(tf.train.SessionRunHook):
tf
.
summary
.
scalar
(
name
,
tensor
)
class
LoggerHook
(
tf
.
train
.
SessionRunHook
):
class
LoggerHook
(
tf
.
estimator
.
SessionRunHook
):
"""
Logs loss and runtime.
"""
def
__init__
(
self
,
loss
,
batch_size
,
log_frequency
):
...
...
@@ -56,7 +55,7 @@ class LoggerHook(tf.train.SessionRunHook):
examples_per_sec
,
sec_per_batch
))
class
LoggerHookEstimator
(
tf
.
train
.
SessionRunHook
):
class
LoggerHookEstimator
(
tf
.
estimator
.
SessionRunHook
):
"""
Logs loss and runtime.
"""
def
__init__
(
self
,
estimator
,
batch_size
,
log_frequency
):
...
...
@@ -93,7 +92,7 @@ class EarlyStopException(Exception):
pass
class
EarlyStopping
(
tf
.
train
.
SessionRunHook
):
class
EarlyStopping
(
tf
.
estimator
.
SessionRunHook
):
"""
Stop training when a monitored quantity has stopped improving.
Based on Keras
'
s EarlyStopping callback:
https://keras.io/callbacks/#earlystopping
...
...
@@ -160,7 +159,7 @@ class EarlyStopping(tf.train.SessionRunHook):
def
begin
(
self
):
self
.
values
=
[]
if
isinstance
(
self
.
monitor
,
s
ix
.
string_types
):
if
isinstance
(
self
.
monitor
,
s
tr
):
self
.
monitor
=
_as_graph_element
(
self
.
monitor
)
else
:
self
.
monitor
=
_as_graph_element
(
self
.
monitor
.
name
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment