Replacing LSTMBlockCell with LSTMBlockFusedCell throws an error.
The full error message:
Traceback (most recent call last):
File "Classification-DL_ULSTM4.py", line 81, in <module>
logits=ULSTM(x_,n_input,n_hidden,n_steps,n_classes)
File "Classification-DL_ULSTM4.py", line 25, in ULSTM
outputs,_=lstm_cell(x,dtype=tf.float32)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/layers/base.py", line 548, in __call__
outputs = super(Layer, self).__call__(inputs, *args, **kwargs)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/base_layer.py", line 819, in __call__
self.name)
File "/tensorflow-1.15.2/python3.7/tensorflow_core/python/keras/engine/input_spec.py", line 155, in assert_input_compatibility
' input tensors. Inputs received: ' + str(inputs))
ValueError: Layer lstm_fused_cell expects 1 inputs, but it received 250 input tensors. Inputs received: [<tf.Tensor 'split:0' shape=(?, 1) dtype=float32>, <tf.Tensor 'split:1' shape=(?, 1) dtype=float32>
previews code
def ULSTM(x,n_input,n_hidden,n_steps,n_classes):
x=tf.transpose(x,[1,0,2])
x=tf.reshape(x,[-1,n_input])
x=tf.split(x,n_steps)
lstm_cell=tf.contrib.rnn.LSTMBlockCell(n_hidden,forget_bias=1.0)
outputs,_=tf.contrib.rnn.static_rnn(lstm_cell,x,dtype=tf.float32)
what I replace
lstm_cell=tf.contrib.rnn.LSTMBlockFusedCell(n_hidden,forget_bias=1.0)
outputs,_=lstm_cell(x,dtype=tf.float32)
args
n_input=1
n_hidden=1
n_steps=250
n_classes=4
tic=time.time()
x=tf.placeholder(tf.float32, [None, 250])
x_=tf.reshape(x,[-1,250,1])
y_=tf.placeholder(tf.float32,[None,4])
logits=ULSTM(x_,n_input,n_hidden,n_steps,n_classes)
learning_rate=0.001
batch_size=16
maxiters=10000
I know LSTMBlockFusedCell is inherited from FusedRNNCell instead of RNNCell, so I cannot use standard tf.nn.static_rnn or tf.nn.dynamic_rnn in which they require RNNCell instance.But I don't know how to change it without error.
Related
im running Nicholas Rennote's TFODCourse.
when i execute the Evaluate the model code:
python Tensorflow\models\research\object_detection\model_main_tf2.py --model_dir=Tensorflow\workspace\models\my_ssd_mobnet --pipeline_config_path=Tensorflow\workspace\models\my_ssd_mobnet\pipeline.config --checkpoint_dir=Tensorflow\workspace\models\my_ssd_mobnet
error occurs like this
Traceback (most recent call last):
File "Tensorflow\models\research\object_detection\model_main_tf2.py", line 115, in <module>
tf.compat.v1.app.run()
File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\platform\app.py", line 40, in run
_run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef)
File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\absl\app.py", line 303, in run
_run_main(main, args)
File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\absl\app.py", line 251, in _run_main
sys.exit(main(argv))
File "Tensorflow\models\research\object_detection\model_main_tf2.py", line 82, in main
model_lib_v2.eval_continuously(
File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\object_detection-0.1-py3.8.egg\object_detection\model_lib_v2.py", line 1151, in eval_continuously
eager_eval_loop(
File "C:\Users\All_Nighter\miniconda3\envs\TF\lib\site-packages\object_detection-0.1-py3.8.egg\object_detection\model_lib_v2.py", line 928, in eager_eval_loop
for i, (features, labels) in enumerate(eval_dataset):
File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 761, in __next__
return self._next_internal()
File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\data\ops\iterator_ops.py", line 744, in _next_internal
ret = gen_dataset_ops.iterator_get_next(
File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\ops\gen_dataset_ops.py", line 2727, in iterator_get_next
_ops.raise_from_not_ok_status(e, name)
File "C:\Users\All_Nighter\AppData\Roaming\Python\Python38\site-packages\tensorflow\python\framework\ops.py", line 6897, in raise_from_not_ok_status
six.raise_from(core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: input must be 4-dimensional[1,1,371,300,3]
[[{{node ResizeImage/resize/ResizeBilinear}}]] [Op:IteratorGetNext]
I can't understand what is input must be 4-dimensional[1,1,371,300,3] means.
i tried Labeling again, and downgrade TF to 2.4.0. but still happend.
ssd_mobilenet model expects input
A three-channel image of variable size - the model does NOT support
batching. The input tensor is a tf.uint8 tensor with shape [1, height,
width, 3] with values in [0, 255]
In this case you are giving 4-dimensional input[1,1,371,300,3],
Reshape your input data as [1,371,300,3].
I have some pre-trained binary Keras model. 3 models in this example. I am trying to make an ensemble model by averaging the predictions of these models. To do so I am taking reference from here example from ensembling model. My code is below
models=list()
for i in os.listdir(model_root): # to get all the models in one list
print(i)
filename = model_root + "/" + i
model = load_model(filename, custom_objects={'KerasLayer': hub.KerasLayer}) # load model
models.append(model)
# ensemble prediction
print(len(models))
yhats = [model.predict(image_data_val) for model in models]
print(np.array(yhats).shape) # (3, 32, 2)
outputs = layers.average(yhats) # averaging the model output
ensemble_model = keras.models.Model(inputs=keras.Input(shape=(None,224,224,3)), outputs=outputs)
To which I am getting the following error
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Pawandeep/Desktop/Python projects/ensemble_image.py", line 68, in <module>
ensemble_model = keras.models.Model(inputs=keras.Input(shape=(None,224,224,3)), outputs=outputs)
File "C:\Python\lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "C:\Python\lib\site-packages\keras\engine\network.py", line 93, in __init__
self._init_graph_network(*args, **kwargs)
File "C:\Python\lib\site-packages\keras\engine\network.py", line 188, in _init_graph_network
'Found: ' + str(x))
ValueError: Output tensors to a Model must be the output of a Keras `Layer` (thus holding past layer metadata). Found: Tensor("average/truediv:0", shape=(32, 2), dtype=float32)
So the overall goal is to ensemble the binary keras model which are trained on sigmoid function. I am not able to understand the error properly, because the outputs is the output of keras model itself.
Traceback after redefining the model as per the suggestion
W0819 16:51:11.051734 11788 ag_logging.py:145] Entity <tensorflow.python.saved_model.function_deserialization.RestoredFunction object at 0x0000020A66459710> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* Tensor("inputs:0", shape=(?, ?, 224, 224, 3), dtype=float32)
* False
* 0.99
Keyword arguments: {}
Expected these arguments to match one of the following 2 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(?, 224, 224, 3), dtype=tf.float32, name='inputs')
* True
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* TensorSpec(shape=(?, 224, 224, 3), dtype=tf.float32, name='inputs')
* False
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/Pawandeep/Desktop/Python projects/ensemble_image.py", line 66, in <module>
yhats = [model(inputs) for model in models]
File "C:/Users/Pawandeep/Desktop/Python projects/ensemble_image.py", line 66, in <listcomp>
yhats = [model(inputs) for model in models]
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 634, in __call__
outputs = call_fn(inputs, *args, **kwargs)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\sequential.py", line 247, in call
return super(Sequential, self).call(inputs, training=training, mask=mask)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\network.py", line 751, in call
return self._run_internal_graph(inputs, training=training, mask=mask)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\network.py", line 893, in _run_internal_graph
output_tensors = layer(computed_tensors, **kwargs)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 634, in __call__
outputs = call_fn(inputs, *args, **kwargs)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\sequential.py", line 247, in call
return super(Sequential, self).call(inputs, training=training, mask=mask)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\network.py", line 751, in call
return self._run_internal_graph(inputs, training=training, mask=mask)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\network.py", line 893, in _run_internal_graph
output_tensors = layer(computed_tensors, **kwargs)
File "C:\Python\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 634, in __call__
outputs = call_fn(inputs, *args, **kwargs)
File "C:\Python\lib\site-packages\tensorflow\python\autograph\impl\api.py", line 149, in wrapper
raise e.ag_error_metadata.to_exception(type(e))
ValueError: in converted code:
relative to C:\Python\lib\site-packages:
tensorflow_hub\keras_layer.py:173 call *
result = smart_cond.smart_cond(training,
tensorflow\python\framework\smart_cond.py:56 smart_cond
return false_fn()
tensorflow\python\saved_model\load.py:323 _call_attribute
return instance.__call__(*args, **kwargs)
tensorflow\python\eager\def_function.py:406 __call__
results = self._stateful_fn(*args, **kwds)
tensorflow\python\eager\function.py:1323 __call__
graph_function, args, kwargs = self._maybe_define_function(args, kwargs)
tensorflow\python\eager\function.py:1652 _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
tensorflow\python\eager\function.py:1545 _create_graph_function
capture_by_value=self._capture_by_value),
tensorflow\python\framework\func_graph.py:715 func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
tensorflow\python\eager\def_function.py:307 wrapped_fn
return weak_wrapped_fn().__wrapped__(*args, **kwds)
tensorflow\python\saved_model\function_deserialization.py:256 restored_function_body
"\n\n".join(signature_descriptions)))
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* Tensor("inputs:0", shape=(?, ?, 224, 224, 3), dtype=float32)
* False
* 0.99
Keyword arguments: {}
Expected these arguments to match one of the following 2 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(?, 224, 224, 3), dtype=tf.float32, name='inputs')
* True
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* TensorSpec(shape=(?, 224, 224, 3), dtype=tf.float32, name='inputs')
* False
* TensorSpec(shape=(), dtype=tf.float32, name='batch_norm_momentum')
Keyword arguments: {}
I found the answer here Output tensors to a Model must be Keras tensors. Found: Tensor #6263
There are some issues with the code in the question
inputs and outputs arguments of the model defined on the following line are disconnected
ensemble_model = keras.models.Model(inputs=keras.Input(shape=(None,224,224,3)), outputs=outputs)
Usage of the model.predict on the following line is not intended usage
yhats = [model.predict(image_data_val) for model in models]
In keras model.predict returns numpy array for a given input. so on the above code line yhats will have list of numpy array
Keras model is callable and will return output tensor computed by the model for given input
The following code will fix the above issues
inputs = keras.Input(shape=(None,224,224,3)) # If the first element of the shape is batch dimension, then it should be removed from the shape parameter
yhats = [model(inputs) for model in models]
outputs = layers.average(yhats)
ensemble_model = keras.models.Model(inputs=inputs, outputs=outputs)
I am importing in some arrays of data to train on but tensorflow is outputting below error.
inp = open('train.csv',"rb")
X = pickle.load(inp)
X = X/255.0
X = np.array(X)
model = keras.Sequential([
keras.layers.Flatten(input_shape=(113, 75, 3)),
keras.layers.Dense(75, activation=tf.nn.relu),
keras.layers.Dense(50, activation=tf.nn.relu),
keras.layers.Dense(75, activation=tf.nn.relu),
keras.layers.Dense(25425, activation=tf.nn.softmax),
keras.layers.Reshape((113, 75, 4))
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(X, X, epochs=5)
I should be able to create an autoencoder but the program outputs this:
Traceback (most recent call last):
File "C:\Users\dalto\Documents\geo4\train.py", line 24, in <module>
model.fit(X, X, epochs=5)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 643, in fit
use_multiprocessing=use_multiprocessing)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 664, in fit
steps_name='steps_per_epoch')
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 383, in model_iteration
batch_outs = f(ins_batch)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\backend.py", line 3510, in __call__
outputs = self._graph_fn(*converted_inputs)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 572, in __call__
return self._call_flat(args)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 671, in _call_flat
outputs = self._inference_function.call(ctx, args)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 445, in call
ctx=ctx)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\execute.py", line 67, in quick_execute
six.raise_from(core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 788175 values, but the requested shape has 1050900
[[node reshape/Reshape (defined at C:\Users\dalto\Documents\geo4\train.py:24) ]] [Op:__inference_keras_scratch_graph_922]
Function call stack:
keras_scratch_graph
If I change the Reshape to (113, 75, 3) I get this it doesn't fix the error it just changes it:
Traceback (most recent call last):
File "C:\Users\dalto\Documents\geo4\train.py", line 24, in <module>
model.fit(X, X, epochs=5)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training.py", line 643, in fit
use_multiprocessing=use_multiprocessing)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 664, in fit
steps_name='steps_per_epoch')
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\engine\training_arrays.py", line 383, in model_iteration
batch_outs = f(ins_batch)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\keras\backend.py", line 3510, in __call__
outputs = self._graph_fn(*converted_inputs)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 572, in __call__
return self._call_flat(args)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 671, in _call_flat
outputs = self._inference_function.call(ctx, args)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\function.py", line 445, in call
ctx=ctx)
File "C:\Users\dalto\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\eager\execute.py", line 67, in quick_execute
six.raise_from(core._status_to_exception(e.code, message), None)
File "<string>", line 3, in raise_from
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible
shapes: [31,113,75] vs. [31,113,75,3]
[[node metrics/accuracy/Equal (defined at
C:\Users\dalto\Documents\geo4\train.py:24) ]] [Op:__inference_keras_scratch_graph_922]
The input and output size after reshape must be same. So, you'll have to use (113, 75, 3) instead of (113, 75, 4).
Now, by using (113, 75, 3), you're getting the unequal error because you're using sparse_categorical_crossentropy as your loss function, you should instead use categorical_crossentropy.
The basic difference between these is that sparse_categorical_crossentropy works when you have direct integers as your label, and categorical_crossentropy works when you have one-hot encoded labels.
Corrected:
inp = open('train.csv',"rb")
X = pickle.load(inp)
X = X/255.0
X = np.array(X)
model = keras.Sequential([
keras.layers.Flatten(input_shape=(113, 75, 3)),
keras.layers.Dense(75, activation=tf.nn.relu),
keras.layers.Dense(50, activation=tf.nn.relu),
keras.layers.Dense(75, activation=tf.nn.relu),
keras.layers.Dense(25425, activation=tf.nn.softmax),
keras.layers.Reshape((113, 75, 4))
])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(X, X, epochs=5)
I'm getting the following error when trying to create a LSTM using TensorFlow:
ValueError: Shapes (?, 83) and (?, 128) are incompatible
The input to the model have the following shape:
(batch_size, time, features) / (50, 68, 83)
Here is the relevant code for the model:
x_text = tf.placeholder(tf.float32, [None, *text.shape[1:]])
cells = tf.contrib.rnn.MultiRNNCell([tf.contrib.rnn.ResidualWrapper(
tf.contrib.rnn.BasicLSTMCell(num_units=units))
for units in [128, 256]
])
text_outputs, text_state = tf.nn.dynamic_rnn(
cell=cells,
inputs=x_text,
dtype=tf.float32,
)
I've tried for so long to figure out what's wrong, but I can't. I've search the entire internett (no, really!) and no one seems to be having the same problem where shapes (?, a) and (?, b) are the problem, but rather all other combinations where the solutions has not helped.
Oh - and here's the stack trace:
Traceback (most recent call last):
File "residual_hierachical_rnn.py", line 97, in <module>
dtype=tf.float32,
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn.py", line 627, in dynamic_rnn
dtype=dtype)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn.py", line 824, in _dynamic_rnn_loop
swap_memory=swap_memory)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 3224, in while_loop
result = loop_context.BuildLoop(cond, body, loop_vars, shape_invariants)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2956, in BuildLoop
pred, body, original_loop_vars, loop_vars, shape_invariants)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 2893, in _BuildLoop
body_result = body(*packed_vars_for_body)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/control_flow_ops.py", line 3194, in <lambda>
body = lambda i, lv: (i + 1, orig_body(*lv))
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn.py", line 795, in _time_step
(output, new_state) = call_cell()
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn.py", line 781, in <lambda>
call_cell = lambda: cell(input_t, state)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn_cell_impl.py", line 232, in __call__
return super(RNNCell, self).__call__(inputs, state)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/layers/base.py", line 717, in __call__
outputs = self.call(inputs, *args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1292, in call
cur_inp, new_state = cell(cur_inp, cur_state)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1168, in __call__
res_outputs = (self._residual_fn or default_residual_fn)(inputs, outputs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1166, in default_residual_fn
nest.map_structure(assert_shape_match, inputs, outputs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 375, in map_structure
structure[0], [func(*x) for x in entries])
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/nest.py", line 375, in <listcomp>
structure[0], [func(*x) for x in entries])
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1163, in assert_shape_match
inp.get_shape().assert_is_compatible_with(out.get_shape())
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/tensor_shape.py", line 844, in assert_is_compatible_with
raise ValueError("Shapes %s and %s are incompatible" % (self, other))
ValueError: Shapes (?, 83) and (?, 128) are incompatible
Thank you so much in advance for any help!!!
As MPKenning says, your LSTM cells should match your input features.
But the fact that you're using a ResidualWrapper forces you to keep the same depth because what it does is summing up the inputs and the outputs of the cells.
If you remove the ResidualWrapper it should work with [83, 256]:
cells = tf.contrib.rnn.MultiRNNCell([
tf.contrib.rnn.BasicLSTMCell(num_units=units)
for units in [83, 256]
])
The unit-size of your LSTM cells should match the number of features. To fix this, use [83, 256].
Also, I'm aware that the connections between the LSTM layers are fully connected, but from what I've been told it's better to keep the unit size in the layers consistent to make things less confusing. In other words, consider using [83, 83] for your unit-sizes.
I was trying to build a 3D convolutional layer using keras. It works fine, but when I added a subsample parameter it crashed. The code:
l_1 = Convolution3D(2, 10,10,10,
border_mode='same',
name = 'l_1',
activation='relu',
subsample = (5,5,5)
)(inputs)
the error is:
Traceback (most recent call last):
File "image_proc_09.py", line 244, in <module>
)(inputs)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in __call__
self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 635, in add_inbound_node
Node.create_node(self, inbound_layers, node_indices, tensor_indices)
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 166, in create_node
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 1234, in call
filter_shape=self.W_shape)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1627, in conv3d
dim_ordering, volume_shape, filter_shape)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 1686, in _old_theano_conv3d
assert(strides == (1, 1, 1))
AssertionError
I am using theano 0.8.2.
Thanks
You cannot use the subsample parameter with border_mode='same'. Use 'valid' or 'full'
Check out the line of code where the assertion error happens