[Solved] Given input shape: ...has different dimension from model input shape

Just in case someone stumbles upon this while following the getting started guide.

If you get an error similar to: Given input shape: (1, 3, 28, 28) has different dimension from model input shape: (1, 1, 28, 28) for input: Input3 at axis: 1

Make sure that the

digit

image is imported correctly, which means not scaled to the nearest Non-power of 2.

The input tensor expects a texture of 28x28, and Unity will try to import it as a 32x32.

Hope this helps.

1 Like

In Unity you can specify to round a imported texture to the nearest power of 2, that’s what is happening with this case.
In your case, you are passing a input tensor of 3 dimensions, and the model is expecting 1 dimension
You can control that with the RenderTextureToTensor api