Cannot Set Batch Size to Anything Aside from 1 on my CNN Model

Hi ptrblck,

My answer is long. Please bear with me. Also, hank you all for your help. It is greatly appreciated!

By activation shape, do you mean the shape coming out of the activation function that goes into the batchnorm layer? For the first convolution (conv1) with 64 output channels, kernel size = 3, and stride =1, the output of the activation function has size [64 , 16198]. As stated in my original post, each “sample” is a row of data from an excel spreadsheet of size [1 , 16200].

As for your second question, I am not sure I understand. I did not initialize the batchnorm layer. I followed some examples in order to figure out how to format the batchnorm layers (see below).

From a previous post ( BatchNorm1d - input shape ), you answered another user and stated that the input size for a batchnorm1d layer should be [batch size, feature size, temp. dim]. I have two questions about this:

  1. What is temp dim and feature size?
  2. Brock (the first commentor on my post) stated that the input to the batchnorm1d layer should be [# channels]. So is either [# channels] or [batch size, feature size, temp. dim] acceptable?

Finally, I found what may be causing the error I previously shared. I store the output of the CNN in a tensor at line 283, as well as the labels so that I can export it later for analysis. When I increase the batch size to greater than 1, the output of the CNN stays at size [1, 3] (the output is the x, y, z location in space of a signal emitter). However, the labels that I am comparing them to has size [batch size, 3]. For batch sizes other than 1, these two do not match.

This may be a silly question, but if I have a batch size of 10 samples, how do I ensure that I am comparing 10 output to their appropriate labels? I assume this is taken care of by the data loaders. My last conv1d layer has output channels = 1 to ensure I have an output of size [1, 3]. Should this be changed to output channels = batch size for cases when I have batch sizes greater than 1?