Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with running #3

Open
sportbilly13 opened this issue Jun 30, 2017 · 6 comments
Open

Problem with running #3

sportbilly13 opened this issue Jun 30, 2017 · 6 comments

Comments

@sportbilly13
Copy link

sportbilly13 commented Jun 30, 2017

Hello Wei
I quite new in neural networks. I tried to run the code with not many data just to see how it will run and I am getting this error
ValueError: Dimensions must be equal, but are 48 and 27 for 'conv2/Conv2D' (op: 'Conv2D') with input shapes: [?,27,27,48], [?,27,27,48].
I am running in Puthon3.5.
Thanks
Vasilis

@WeiTang114
Copy link
Owner

@sportbilly13
Could you paste more messages?
At which line do you get this error?
The model does not use channel 48 at any layer so this is weird.

@sportbilly13
Copy link
Author

The console I am getting
start loading data
dataset inited
total size: 4
dataset inited
total size: 4
done loading data, time= 0.0006747245788574219
train() called
training size: 4
conv1 [None, 55, 55, 96]
pool1 [None, 27, 27, 96]
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py", line 671, in _call_cpp_shape_fn_impl
input_tensors_as_shapes, status)
File "/usr/lib/python3.5/contextlib.py", line 66, in exit
next(self.gen)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimensions must be equal, but are 48 and 27 for 'conv2/Conv2D' (op: 'Conv2D') with input shapes: [?,27,27,48], [?,27,27,48].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "train.py", line 190, in
main(sys.argv)
File "train.py", line 179, in main
train(dataset_train, dataset_val, FLAGS.weights, FLAGS.caffemodel)
File "train.py", line 57, in train
fc8 = model.inference_multiview(view_, globals.NUM_CLASSES, keep_prob_)
File "/home/sportbilly/workspace/mvcnn/model.py", line 142, in inference_multiview
conv2 = _conv('conv2', pool1, [5, 5, 96, 256], group=2, reuse=reuse)
File "/home/sportbilly/workspace/mvcnn/model.py", line 88, in _conv
output_groups = [convolve(i,k) for i, k in zip(input_groups, kernel_groups)]
File "/home/sportbilly/workspace/mvcnn/model.py", line 88, in
output_groups = [convolve(i,k) for i, k in zip(input_groups, kernel_groups)]
File "/home/sportbilly/workspace/mvcnn/model.py", line 71, in
convolve = lambda i, k: tf.nn.conv2d(i,k,strides, padding=padding)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 403, in conv2d
data_format=data_format, name=name)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 768, in apply_op
op_def=op_def)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 2338, in create_op
set_shapes_for_outputs(ret)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1719, in set_shapes_for_outputs
shapes = shape_func(op)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/ops.py", line 1669, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/common_shapes.py", line 676, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 48 and 27 for 'conv2/Conv2D' (op: 'Conv2D') with input shapes: [?,27,27,48], [?,27,27,48].

I think in the def_conv the time it is called for the conv2 layer it gets in the else statement and stops at the line of
output_groups = [convolve(i,k) for i, k in zip(input_groups, kernel_groups)] line 88
Thanks

@WeiTang114
Copy link
Owner

@sportbilly13
Did you modify the input placeholder to a smaller size? (eg. 55x55 as I see in your output?)
It should be 227x227.

@sportbilly13
Copy link
Author

No
In the def train
view_ = tf.placeholder('float32', shape=(None, V, 227, 227, 3), name='im0')

and in the model is call the conv1
conv1 = _conv('conv1', view, [11, 11, 3, 96], [1, 4, 4, 1], 'VALID', reuse=reuse)
Thanks

@WeiTang114
Copy link
Owner

@sportbilly13
I tested conv2d and find while I do this I get the same error:

a = tf.placeholder('float32', [None, 27,27,48])
k = tf.Variable(np.zeros((5,5,48,256)), dtype='float32')

# This get the same error with yours
tf.nn.conv2d(a,a,[1,1,1,1], padding='SAME')

# This is fine
tf.nn.conv2d(a,k,[1,1,1,1], padding='SAME')

Thus I guess the reason of the error is you convolve(i, k) at line 88 unexpectedly runs like convolve(i, i). I did not get how this happen and need more testing. Maybe it's from some difference between python2 and python3? (I'm using python2.7). Could you try it with python2?

@sportbilly13
Copy link
Author

Thanks very much
I will try it with python 2 and also search a little bit more if I could find something.
I will let you know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants