Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Unable to load model with 'th' image_dim_ordering #55

Closed
bsrinivas8687 opened this issue Mar 11, 2017 · 2 comments
Closed

Unable to load model with 'th' image_dim_ordering #55

bsrinivas8687 opened this issue Mar 11, 2017 · 2 comments

Comments

@bsrinivas8687
Copy link

@rykov8

Hi, I am trying to load model with 'th' image_dim_ordering and 'tensorflow' backend, but it raising some errors. Is it possible to run model with 'th' image_dim_order?

Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
  File "./test.py", line 30, in <module>
    model = SSD300(input_shape, num_classes=NUM_CLASSES)
  File "/home/dummy/ssd_keras/ssd.py", line 77, in SSD300
    net['conv4_3_norm'] = Normalize(20, name='conv4_3_norm')(net['conv4_3'])
  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 "/home/dummy/ssd_keras/ssd_layers.py", line 43, in call
    output *= self.gamma
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 814, in binary_op_wrapper
    return func(x, y, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/math_ops.py", line 987, in _mul_dispatch
    return gen_math_ops.mul(x, y, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_math_ops.py", line 1613, in mul
    result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
    op_def=op_def)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2242, in create_op
    set_shapes_for_outputs(ret)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1617, in set_shapes_for_outputs
    shapes = shape_func(op)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1568, in call_with_requiring
    return call_cpp_shape_fn(op, require_shape_fn=True)
  File "/usr/local/lib/python2.7/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/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl
    raise ValueError(err.message)
ValueError: Dimensions must be equal, but are 38 and 512 for 'mul' (op: 'Mul') with input shapes: [?,512,38,38], [512].
@bsrinivas8687
Copy link
Author

bsrinivas8687 commented Mar 11, 2017

@rykov8

I think the problem is with Normalize layer.
To run the model with 'th' image_dim_ordering, we must have same input_shapes.
So instead of Normalize layer can we use BatchNormalization Layer which has 4D shape?

@tomochi222
Copy link

According to the official, for three-dimensional data, "tf" is regarded as (conv_dim1, conv_dim2, conv_dim3, channels) and "th" is considered as (channels, conv_dim1, conv_dim2, conv_dim3).

So, It may be impossible to load the model with "th" image_dim_order. Would you already try to load the model with "tf" image_dim_order?

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

No branches or pull requests

2 participants