Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
2e82b882
Commit
2e82b882
authored
Sep 26, 2018
by
Menglong Zhu
Committed by
dreamdragon
Oct 24, 2018
Browse files
Adding the option to clip lstm states to a range.
PiperOrigin-RevId: 214714611
parent
b9665e9b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
research/lstm_object_detection/lstm/lstm_cells.py
research/lstm_object_detection/lstm/lstm_cells.py
+5
-0
No files found.
research/lstm_object_detection/lstm/lstm_cells.py
View file @
2e82b882
...
@@ -45,6 +45,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
...
@@ -45,6 +45,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
forget_bias
=
1.0
,
forget_bias
=
1.0
,
activation
=
tf
.
tanh
,
activation
=
tf
.
tanh
,
flattened_state
=
False
,
flattened_state
=
False
,
clip_state
=
False
,
output_bottleneck
=
False
,
output_bottleneck
=
False
,
visualize_gates
=
True
):
visualize_gates
=
True
):
"""Initializes the basic LSTM cell.
"""Initializes the basic LSTM cell.
...
@@ -57,6 +58,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
...
@@ -57,6 +58,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
activation: Activation function of the inner states.
activation: Activation function of the inner states.
flattened_state: if True, state tensor will be flattened and stored as
flattened_state: if True, state tensor will be flattened and stored as
a 2-d tensor. Use for exporting the model to tfmini.
a 2-d tensor. Use for exporting the model to tfmini.
clip_state: if True, clip state between [-6, 6].
output_bottleneck: if True, the cell bottleneck will be concatenated
output_bottleneck: if True, the cell bottleneck will be concatenated
to the cell output.
to the cell output.
visualize_gates: if True, add histogram summaries of all gates
visualize_gates: if True, add histogram summaries of all gates
...
@@ -69,6 +71,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
...
@@ -69,6 +71,7 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
self
.
_activation
=
activation
self
.
_activation
=
activation
self
.
_viz_gates
=
visualize_gates
self
.
_viz_gates
=
visualize_gates
self
.
_flattened_state
=
flattened_state
self
.
_flattened_state
=
flattened_state
self
.
_clip_state
=
clip_state
self
.
_output_bottleneck
=
output_bottleneck
self
.
_output_bottleneck
=
output_bottleneck
self
.
_param_count
=
self
.
_num_units
self
.
_param_count
=
self
.
_num_units
for
dim
in
self
.
_output_size
:
for
dim
in
self
.
_output_size
:
...
@@ -138,6 +141,8 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
...
@@ -138,6 +141,8 @@ class BottleneckConvLSTMCell(tf.contrib.rnn.RNNCell):
new_c
=
(
new_c
=
(
c
*
tf
.
sigmoid
(
f
+
self
.
_forget_bias
)
+
c
*
tf
.
sigmoid
(
f
+
self
.
_forget_bias
)
+
tf
.
sigmoid
(
i
)
*
self
.
_activation
(
j
))
tf
.
sigmoid
(
i
)
*
self
.
_activation
(
j
))
if
self
.
_clip_state
:
new_c
=
tf
.
clip_by_value
(
new_c
,
-
6
,
6
)
new_h
=
self
.
_activation
(
new_c
)
*
tf
.
sigmoid
(
o
)
new_h
=
self
.
_activation
(
new_c
)
*
tf
.
sigmoid
(
o
)
# summary of cell output and new state
# summary of cell output and new state
if
self
.
_viz_gates
:
if
self
.
_viz_gates
:
...
...
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