Issues with using stateful in StackedRNN cells
$begingroup$
I am having issues with using the 'stateful' feature when building stacked RNN using LSTMCell object. I am following the instructions on tensorflow on how to set 'stateful = True' by passing the 'batch_shape' to the input layer and the 'batch_input_shape' to the first cell, and also tried to set it in the second cell but it still does not work; tried various combinations but nothing works. The code only works with one cell but not with more than one. I am not sure what I am missing.
The problem I am working on is Sentiment Analysis. 292 is the sequence length I am passing to predict if the sentiment is 1 or 0.
I realize I could use the Sequential model of Keras but I would like to learn the finer features of tensorflow.
import tensorflow as tf
tf.reset_default_graph()
batch_size = 10
embed_size = 5
dropout = 0.5
n_unique_words = 102966
ntimesteps = 292
x = tf.placeholder(dtype = tf.int32, shape = (batch_size, ntimesteps), name='tf_x')
print(x)
y = tf.placeholder(dtype = tf.float32, shape = (batch_size), name = 'tf_y')
print(y)
embed_variable = tf.get_variable(name = 'embedding', shape = [n_unique_words, embed_size], initializer=tf.glorot_uniform_initializer)
print(embed_variable)
embed_x = tf.nn.embedding_lookup(embed_variable, x, name = 'embedded_x')
print(embed_x)
cell1 = tf.keras.layers.LSTMCell(units = 256, batch_input_shape = (10,292,5), dtype = tf.float32)#, dropout=dropout, name = 'lstm1')
print(cell1)
cell2 = tf.keras.layers.LSTMCell(units = 512, batch_input_shape = (10,292,5), dtype = tf.float32)#, name='lstm2', recurrent_dropout=0.5)
print(cell2)
rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
print(rnn_object)
Output:
Tensor("tf_x:0", shape=(10, 292), dtype=int32)
Tensor("tf_y:0", shape=(10,), dtype=float32)
<tf.Variable 'embedding:0' shape=(102966, 5) dtype=float32_ref>
Tensor("embedded_x/Identity:0", shape=(10, 292, 5), dtype=float32)
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3b38>
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3fd0>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-641a99b06a11> in <module>
32 rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
33 rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
---> 34 return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
35
36
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
699
700 if initial_state is None and constants is None:
--> 701 return super(RNN, self).__call__(inputs, **kwargs)
702
703 # If any of `initial_state` or `constants` are specified and are Keras
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, inputs, *args, **kwargs)
536 if not self.built:
537 # Build layer if applicable (if the `build` method has been overridden).
--> 538 self._maybe_build(inputs)
539 # We must set self.built since user defined build functions are not
540 # constrained to set self.built.
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
1601 # Only call `build` if the user has manually overridden the build method.
1602 if not hasattr(self.build, '_is_default'):
-> 1603 self.build(input_shapes)
1604
1605 def __setattr__(self, name, value):
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in build(self, input_shape)
634 ]
635 if self.stateful:
--> 636 self.reset_states()
637 self.built = True
638
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in reset_states(self, states)
904 K.set_value(state,
905 np.zeros([batch_size] +
--> 906 tensor_shape.as_shape(dim).as_list()))
907 else:
908 K.set_value(self.states[0], np.zeros(
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in set_value(x, value)
2831 (of the same shape).
2832 """
-> 2833 value = np.asarray(value, dtype=dtype(x))
2834 if ops.executing_eagerly_outside_functions():
2835 x.assign(value)
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in dtype(x)
1013 ```
1014 """
-> 1015 return x.dtype.base_dtype.name
1016
1017
AttributeError: 'list' object has no attribute 'dtype'
python tensorflow rnn
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I am having issues with using the 'stateful' feature when building stacked RNN using LSTMCell object. I am following the instructions on tensorflow on how to set 'stateful = True' by passing the 'batch_shape' to the input layer and the 'batch_input_shape' to the first cell, and also tried to set it in the second cell but it still does not work; tried various combinations but nothing works. The code only works with one cell but not with more than one. I am not sure what I am missing.
The problem I am working on is Sentiment Analysis. 292 is the sequence length I am passing to predict if the sentiment is 1 or 0.
I realize I could use the Sequential model of Keras but I would like to learn the finer features of tensorflow.
import tensorflow as tf
tf.reset_default_graph()
batch_size = 10
embed_size = 5
dropout = 0.5
n_unique_words = 102966
ntimesteps = 292
x = tf.placeholder(dtype = tf.int32, shape = (batch_size, ntimesteps), name='tf_x')
print(x)
y = tf.placeholder(dtype = tf.float32, shape = (batch_size), name = 'tf_y')
print(y)
embed_variable = tf.get_variable(name = 'embedding', shape = [n_unique_words, embed_size], initializer=tf.glorot_uniform_initializer)
print(embed_variable)
embed_x = tf.nn.embedding_lookup(embed_variable, x, name = 'embedded_x')
print(embed_x)
cell1 = tf.keras.layers.LSTMCell(units = 256, batch_input_shape = (10,292,5), dtype = tf.float32)#, dropout=dropout, name = 'lstm1')
print(cell1)
cell2 = tf.keras.layers.LSTMCell(units = 512, batch_input_shape = (10,292,5), dtype = tf.float32)#, name='lstm2', recurrent_dropout=0.5)
print(cell2)
rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
print(rnn_object)
Output:
Tensor("tf_x:0", shape=(10, 292), dtype=int32)
Tensor("tf_y:0", shape=(10,), dtype=float32)
<tf.Variable 'embedding:0' shape=(102966, 5) dtype=float32_ref>
Tensor("embedded_x/Identity:0", shape=(10, 292, 5), dtype=float32)
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3b38>
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3fd0>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-641a99b06a11> in <module>
32 rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
33 rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
---> 34 return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
35
36
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
699
700 if initial_state is None and constants is None:
--> 701 return super(RNN, self).__call__(inputs, **kwargs)
702
703 # If any of `initial_state` or `constants` are specified and are Keras
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, inputs, *args, **kwargs)
536 if not self.built:
537 # Build layer if applicable (if the `build` method has been overridden).
--> 538 self._maybe_build(inputs)
539 # We must set self.built since user defined build functions are not
540 # constrained to set self.built.
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
1601 # Only call `build` if the user has manually overridden the build method.
1602 if not hasattr(self.build, '_is_default'):
-> 1603 self.build(input_shapes)
1604
1605 def __setattr__(self, name, value):
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in build(self, input_shape)
634 ]
635 if self.stateful:
--> 636 self.reset_states()
637 self.built = True
638
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in reset_states(self, states)
904 K.set_value(state,
905 np.zeros([batch_size] +
--> 906 tensor_shape.as_shape(dim).as_list()))
907 else:
908 K.set_value(self.states[0], np.zeros(
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in set_value(x, value)
2831 (of the same shape).
2832 """
-> 2833 value = np.asarray(value, dtype=dtype(x))
2834 if ops.executing_eagerly_outside_functions():
2835 x.assign(value)
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in dtype(x)
1013 ```
1014 """
-> 1015 return x.dtype.base_dtype.name
1016
1017
AttributeError: 'list' object has no attribute 'dtype'
python tensorflow rnn
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variablestateful = Trueis something different, turn it False. And I don't think removing thestatefulmake this error go away, you have a problem with your input, see this stackoverflow post.
$endgroup$
– Esmailian
4 hours ago
add a comment |
$begingroup$
I am having issues with using the 'stateful' feature when building stacked RNN using LSTMCell object. I am following the instructions on tensorflow on how to set 'stateful = True' by passing the 'batch_shape' to the input layer and the 'batch_input_shape' to the first cell, and also tried to set it in the second cell but it still does not work; tried various combinations but nothing works. The code only works with one cell but not with more than one. I am not sure what I am missing.
The problem I am working on is Sentiment Analysis. 292 is the sequence length I am passing to predict if the sentiment is 1 or 0.
I realize I could use the Sequential model of Keras but I would like to learn the finer features of tensorflow.
import tensorflow as tf
tf.reset_default_graph()
batch_size = 10
embed_size = 5
dropout = 0.5
n_unique_words = 102966
ntimesteps = 292
x = tf.placeholder(dtype = tf.int32, shape = (batch_size, ntimesteps), name='tf_x')
print(x)
y = tf.placeholder(dtype = tf.float32, shape = (batch_size), name = 'tf_y')
print(y)
embed_variable = tf.get_variable(name = 'embedding', shape = [n_unique_words, embed_size], initializer=tf.glorot_uniform_initializer)
print(embed_variable)
embed_x = tf.nn.embedding_lookup(embed_variable, x, name = 'embedded_x')
print(embed_x)
cell1 = tf.keras.layers.LSTMCell(units = 256, batch_input_shape = (10,292,5), dtype = tf.float32)#, dropout=dropout, name = 'lstm1')
print(cell1)
cell2 = tf.keras.layers.LSTMCell(units = 512, batch_input_shape = (10,292,5), dtype = tf.float32)#, name='lstm2', recurrent_dropout=0.5)
print(cell2)
rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
print(rnn_object)
Output:
Tensor("tf_x:0", shape=(10, 292), dtype=int32)
Tensor("tf_y:0", shape=(10,), dtype=float32)
<tf.Variable 'embedding:0' shape=(102966, 5) dtype=float32_ref>
Tensor("embedded_x/Identity:0", shape=(10, 292, 5), dtype=float32)
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3b38>
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3fd0>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-641a99b06a11> in <module>
32 rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
33 rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
---> 34 return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
35
36
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
699
700 if initial_state is None and constants is None:
--> 701 return super(RNN, self).__call__(inputs, **kwargs)
702
703 # If any of `initial_state` or `constants` are specified and are Keras
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, inputs, *args, **kwargs)
536 if not self.built:
537 # Build layer if applicable (if the `build` method has been overridden).
--> 538 self._maybe_build(inputs)
539 # We must set self.built since user defined build functions are not
540 # constrained to set self.built.
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
1601 # Only call `build` if the user has manually overridden the build method.
1602 if not hasattr(self.build, '_is_default'):
-> 1603 self.build(input_shapes)
1604
1605 def __setattr__(self, name, value):
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in build(self, input_shape)
634 ]
635 if self.stateful:
--> 636 self.reset_states()
637 self.built = True
638
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in reset_states(self, states)
904 K.set_value(state,
905 np.zeros([batch_size] +
--> 906 tensor_shape.as_shape(dim).as_list()))
907 else:
908 K.set_value(self.states[0], np.zeros(
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in set_value(x, value)
2831 (of the same shape).
2832 """
-> 2833 value = np.asarray(value, dtype=dtype(x))
2834 if ops.executing_eagerly_outside_functions():
2835 x.assign(value)
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in dtype(x)
1013 ```
1014 """
-> 1015 return x.dtype.base_dtype.name
1016
1017
AttributeError: 'list' object has no attribute 'dtype'
python tensorflow rnn
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I am having issues with using the 'stateful' feature when building stacked RNN using LSTMCell object. I am following the instructions on tensorflow on how to set 'stateful = True' by passing the 'batch_shape' to the input layer and the 'batch_input_shape' to the first cell, and also tried to set it in the second cell but it still does not work; tried various combinations but nothing works. The code only works with one cell but not with more than one. I am not sure what I am missing.
The problem I am working on is Sentiment Analysis. 292 is the sequence length I am passing to predict if the sentiment is 1 or 0.
I realize I could use the Sequential model of Keras but I would like to learn the finer features of tensorflow.
import tensorflow as tf
tf.reset_default_graph()
batch_size = 10
embed_size = 5
dropout = 0.5
n_unique_words = 102966
ntimesteps = 292
x = tf.placeholder(dtype = tf.int32, shape = (batch_size, ntimesteps), name='tf_x')
print(x)
y = tf.placeholder(dtype = tf.float32, shape = (batch_size), name = 'tf_y')
print(y)
embed_variable = tf.get_variable(name = 'embedding', shape = [n_unique_words, embed_size], initializer=tf.glorot_uniform_initializer)
print(embed_variable)
embed_x = tf.nn.embedding_lookup(embed_variable, x, name = 'embedded_x')
print(embed_x)
cell1 = tf.keras.layers.LSTMCell(units = 256, batch_input_shape = (10,292,5), dtype = tf.float32)#, dropout=dropout, name = 'lstm1')
print(cell1)
cell2 = tf.keras.layers.LSTMCell(units = 512, batch_input_shape = (10,292,5), dtype = tf.float32)#, name='lstm2', recurrent_dropout=0.5)
print(cell2)
rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
print(rnn_object)
Output:
Tensor("tf_x:0", shape=(10, 292), dtype=int32)
Tensor("tf_y:0", shape=(10,), dtype=float32)
<tf.Variable 'embedding:0' shape=(102966, 5) dtype=float32_ref>
Tensor("embedded_x/Identity:0", shape=(10, 292, 5), dtype=float32)
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3b38>
<tensorflow.python.keras.layers.recurrent.LSTMCell object at 0x7fd8088a3fd0>
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-641a99b06a11> in <module>
32 rnn_input = tf.keras.Input(batch_shape = (batch_size, 292, 5), dtype = tf.float32) #shape = (batch_size, 292))#
33 rnn_object = tf.keras.layers.RNN(cell = [cell1, cell2], batch_size = 10, return_sequences = True,
---> 34 return_state = True, stateful = True, dtype = tf.float32)(rnn_input)
35
36
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
699
700 if initial_state is None and constants is None:
--> 701 return super(RNN, self).__call__(inputs, **kwargs)
702
703 # If any of `initial_state` or `constants` are specified and are Keras
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, inputs, *args, **kwargs)
536 if not self.built:
537 # Build layer if applicable (if the `build` method has been overridden).
--> 538 self._maybe_build(inputs)
539 # We must set self.built since user defined build functions are not
540 # constrained to set self.built.
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py in _maybe_build(self, inputs)
1601 # Only call `build` if the user has manually overridden the build method.
1602 if not hasattr(self.build, '_is_default'):
-> 1603 self.build(input_shapes)
1604
1605 def __setattr__(self, name, value):
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in build(self, input_shape)
634 ]
635 if self.stateful:
--> 636 self.reset_states()
637 self.built = True
638
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/layers/recurrent.py in reset_states(self, states)
904 K.set_value(state,
905 np.zeros([batch_size] +
--> 906 tensor_shape.as_shape(dim).as_list()))
907 else:
908 K.set_value(self.states[0], np.zeros(
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in set_value(x, value)
2831 (of the same shape).
2832 """
-> 2833 value = np.asarray(value, dtype=dtype(x))
2834 if ops.executing_eagerly_outside_functions():
2835 x.assign(value)
~/anaconda3/envs/condapy36/lib/python3.6/site-packages/tensorflow/python/keras/backend.py in dtype(x)
1013 ```
1014 """
-> 1015 return x.dtype.base_dtype.name
1016
1017
AttributeError: 'list' object has no attribute 'dtype'
python tensorflow rnn
python tensorflow rnn
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 5 hours ago
Tasos
1,42611038
1,42611038
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 5 hours ago
Sameer KesavaSameer Kesava
1
1
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Sameer Kesava is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variablestateful = Trueis something different, turn it False. And I don't think removing thestatefulmake this error go away, you have a problem with your input, see this stackoverflow post.
$endgroup$
– Esmailian
4 hours ago
add a comment |
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variablestateful = Trueis something different, turn it False. And I don't think removing thestatefulmake this error go away, you have a problem with your input, see this stackoverflow post.
$endgroup$
– Esmailian
4 hours ago
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variable
stateful = True is something different, turn it False. And I don't think removing the stateful make this error go away, you have a problem with your input, see this stackoverflow post.$endgroup$
– Esmailian
4 hours ago
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variable
stateful = True is something different, turn it False. And I don't think removing the stateful make this error go away, you have a problem with your input, see this stackoverflow post.$endgroup$
– Esmailian
4 hours ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "557"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sameer Kesava is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48688%2fissues-with-using-stateful-in-stackedrnn-cells%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sameer Kesava is a new contributor. Be nice, and check out our Code of Conduct.
Sameer Kesava is a new contributor. Be nice, and check out our Code of Conduct.
Sameer Kesava is a new contributor. Be nice, and check out our Code of Conduct.
Sameer Kesava is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Data Science Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f48688%2fissues-with-using-stateful-in-stackedrnn-cells%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
Welcome to the site! All LSTMs are stateful by definition, you cannot turn it off. Variable
stateful = Trueis something different, turn it False. And I don't think removing thestatefulmake this error go away, you have a problem with your input, see this stackoverflow post.$endgroup$
– Esmailian
4 hours ago