You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My tensorflow version is 1.8.0
I clone the code to my computer and download the mnist_cluttered_60x60_6distortions.npz dataset into ./data/.
When I run the main.py, I get the following ERROR:
Loading the data...
Building ConvNet...
Traceback (most recent call last):
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 517, in make_tensor_proto
str_values = [compat.as_bytes(x) for x in proto_values]
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 517, in <listcomp>
str_values = [compat.as_bytes(x) for x in proto_values]
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/util/compat.py", line 67, in as_bytes
(bytes_or_text,))
TypeError: Expected binary or unicode string, got -1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 422, in <module>
main()
File "main.py", line 275, in main
pool3_flat, pool3_size = Flatten(pool3)
File "/home/LiChenyang/spatial-transformer-network/utils/layer_utils.py", line 85, in Flatten
layer_flat = tf.reshape(layer, [-1, num_features])
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/gen_array_ops.py", line 6113, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper
raise err
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 510, in _apply_op_helper
preferred_dtype=default_dtype)
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1104, in internal_convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 235, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/constant_op.py", line 214, in constant
value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/home/xinlab/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py", line 521, in make_tensor_proto
"supported type." % (type(values), values))
TypeError: Failed to convert object of type <class 'list'> to Tensor. Contents: [-1, None]. Consider casting elements to a supported type.
LiChenyang@ubuntu:~/spatial-transformer-network$
Any idea to fix this problem?
The text was updated successfully, but these errors were encountered:
I guess the error is due to the last dimension of the target shape is None(i.e. [-1, None]) when execute the code: layer_flat = tf.reshape(layer, [-1, num_features]).
I try to print the h_trans and pool3 in main(), and I get:
The second and third dimension of h_trans is '?', which makes num_features in Flatten() None.
To verify this idea, I add a new function in ./utils/layer_utils.py:
def Flatten_test(layer):
"""
Handy function for flattening the result of a conv2D or
maxpool2D to be used for a fully-connected (affine) layer.
"""
# layer_shape = layer.get_shape()
# # num_features = tf.reduce_prod(tf.shape(layer)[1:])
# num_features = layer_shape[1:].num_elements()
num_features = 8 * 8 * 128
layer_flat = tf.reshape(layer, [-1, num_features])
return layer_flat, num_features
Manually calculate the num_features and change: pool3_flat, pool3_size = Flatten(pool3)
into pool3_flat, pool3_size = Flatten_test(pool3)
Finally, I can successfully run the main.py.
However, I still puzzle about why the num_features is None in Flatten()
My tensorflow version is 1.8.0
I clone the code to my computer and download the
mnist_cluttered_60x60_6distortions.npz
dataset into./data/
.When I run the main.py, I get the following ERROR:
Any idea to fix this problem?
The text was updated successfully, but these errors were encountered: