question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

own dataset: Shapes (64, 4, 4, 256) and (64, 3, 3, 256) are not compatible

See original GitHub issue

Hi there,

When using my own dataset (28x28, grayscale), I get an error for this line in model.py:

g_optim = tf.train.AdamOptimizer(config.learning_rate, beta1=config.beta1) \ .minimize(self.g_loss, var_list=self.g_vars)

error: Traceback (most recent call last): File "...tensorflow/python/framework/tensor_shape.py", line 575, in merge_with new_dims.append(dim.merge_with(other[i])) File "...tensorflow/python/framework/tensor_shape.py", line 133, in merge_with self.assert_is_compatible_with(other) File "...tensorflow/python/framework/tensor_shape.py", line 108, in assert_is_compatible_with % (self, other)) ValueError: Dimensions 4 and 3 are not compatible During handling of the above exception, another exception occurred: Traceback (most recent call last): File "main.py", line 74, in <module> tf.app.run() File "...tensorflow/python/platform/app.py", line 30, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "main.py", line 59, in main dcgan.train(FLAGS) File "...DCGAN-tensorflow/model.py", line 139, in train .minimize(self.g_loss, var_list=self.g_vars) File "...tensorflow/python/training/optimizer.py", line 196, in minimize grad_loss=grad_loss) File "...tensorflow/python/training/optimizer.py", line 253, in compute_gradients colocate_gradients_with_ops=colocate_gradients_with_ops) File "...tensorflow/python/ops/gradients.py", line 491, in gradients in_grad.set_shape(t_in.get_shape()) File "...tensorflow/python/framework/ops.py", line 408, in set_shape self._shape = self._shape.merge_with(shape) File "...tensorflow/python/framework/tensor_shape.py", line 579, in merge_with (self, other)) ValueError: Shapes (64, 4, 4, 256) and (64, 3, 3, 256) are not compatible

Any advice on how to fix this?

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
carpedm20commented, Jan 15, 2017

@hercky Oh I see. The problem was the size of input is too small for 4 layer networks and it’s not dividable. I think it’s tricky problem that a depth of network highly depends on input width, height and there is no one answer for it. I’ll just add a raise Exception code if the input size is “too small” for the current network design and suggest people to change it.

1reaction
carpedm20commented, Jan 7, 2017

I’m not sure but the fast simple bypass might be adding tf.image.resize_images right after

self.images = tf.placeholder(tf.float32, 
                            [self.batch_size] + [self.output_size, self.output_size, self.c_dim],
                            name='real_images')

is defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Keras: Trying to model.predict() gives "ValueError: Tensor's ...
I'm following the TensorFlow Keras tutorial for text generation. ... ValueError: Tensor's shape (9, 64, 256) is not compatible with supplied ...
Read more >
tf.data: Build TensorFlow input pipelines
The tf.data API enables you to build complex input pipelines from simple, reusable pieces. For example, the pipeline for an image model might...
Read more >
CS231n Convolutional Neural Networks for Visual Recognition
We use three main types of layers to build ConvNet architectures: Convolutional Layer, Pooling Layer, and Fully-Connected Layer (exactly as seen in regular ......
Read more >
Multiclass semantic segmentation using DeepLabV3+ - Keras
Train Dataset: <BatchDataset shapes: ((4, 512, 512, 3), (4, 512, 512, 1)), ... conv1_conv (Conv2D) (None, 256, 256, 64) 9472 conv1_pad[0][0] ...
Read more >
Change input shape dimensions for fine-tuning with Keras
Figure 3: A subset of the Kaggle Dogs vs. Cats dataset is used for this Keras input shape example. Using a smaller dataset...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found