Skip to content
Advertisement

What’s the reason of the error ValueError: Expected more than 1 value per channel?

reference fast.ai

github repository of fast.ai (as the code elevates the library which is built on top of PyTorch)

Please scroll the discussion a bit

I am running the following code, and get an error while trying to pass the data to the predict_array function

The code is failing when i am trying to use it to predict directly on a single image but it run’s perfectly when that same image is in a test folder

JavaScript

Here’s the Traceback I am Getting

JavaScript

Things I have Tried

  • np.expand_dims(IMG,axis=0) or image = image[..., np.newaxis]

  • Tried a different way of reading the image

    JavaScript

BTW the error still remains

JavaScript

Can’t find any reference in The Google search also..

Advertisement

Answer

It will fail on batches of size 1 if we use feature-wise batch normalization.

As Batch normalization computes:

JavaScript

If we have one sample per batch then mean(x) = x, and the output will be entirely zero (ignoring the bias). We can’t use that for learning…

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement