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.

Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution'

See original GitHub issue

I got this error message when declaring the input layer in Keras.

ValueError: Negative dimension size caused by subtracting 3 from 1 for 'conv2d_2/convolution' (op: 'Conv2D') with input shapes: [?,1,28,28], [3,3,28,32].

My code is like this

model.add(Convolution2D(32, 3, 3, activation='relu', input_shape=(1,28,28)))

Sample application: https://github.com/IntellijSys/tensorflow/blob/master/Keras.ipynb

Please advice. Thank you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:10

github_iconTop GitHub Comments

25reactions
warpdrivcommented, Nov 1, 2017

@datomnurdin , that link fixed the same error I have. My line of code is (note the data_format arg):

model.add(Convolution2D(32, (3, 3), activation='relu', input_shape=(1,28,28), data_format='channels_first'))

Read more comments on GitHub >

github_iconTop Results From Across the Web

Negative dimension size caused by subtracting 3 from 1 for ...
Your issue comes from the image_ordering_dim in keras.json . From Keras Image Processing doc: dim_ordering: One of {"th", "tf"}.
Read more >
Error: Negative dimension size caused by subtracting 3 from 1
Here's the error: Negative dimension size caused by subtracting 3 from 1 for 'conv2d_8/convolution' (op: 'Conv2D') with input shapes: [?,1,1 ...
Read more >
Negative dimension size caused by subtracting 3 from 1 for ...
PYTHON : Negative dimension size caused by subtracting 3 from 1 for 'Conv2D' [ Gift : Animated Search Engine ...
Read more >
ValueError: Negative dimension size caused by subtracting 3 ...
Binary classification problem: I want to have One input layer(optional), One Conv1D layer then output layer of 1 neuron predicting either 1 or...
Read more >
Negative dimension size caused by subtracting 2 from 1 - Reddit
ValueError : Negative dimension size caused by subtracting 2 from 1 ... (3, 3), activation='relu')) model.add(MaxPooling2D(pool_size=(2, ...
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