I’m converting a list of 3d numpy arrays (from an .npz file) into a tensor like so:
data = np.load("path.npz",encoding='bytes')
data = torch.from_numpy(data['arr_0'].unsqueeze(1).float()
train_kwargs = {'data_tensor':data}
The images are 8 channel 96X96 pixels, and currently I’m using a batch size of 64. So my tensor object has a size of
torch.Size([64,1,8,95,95])
.
Here is a portion of the code I’ve been using in my encoding portion of my network:
def __init__(self, z_dim=10, nc=3):
super(VAE, self).__init__()
self.z_dim = z_dim
self.nc = nc
self.encoder = nn.Sequential(
nn.Conv2d(nc, 32, 4, 2, 1), # B, 32, 32, 32
nn.ReLU(True),
nn.Conv2d(32, 32, 4, 2, 1), # B, 32, 16, 16
nn.ReLU(True),
nn.Conv2d(32, 64, 4, 2, 1), # B, 64, 8, 8
nn.ReLU(True),
nn.Conv2d(64, 64, 4, 2, 1), # B, 64, 4, 4
nn.ReLU(True),
nn.Conv2d(64, 256, 4, 1), # B, 256, 1, 1
nn.ReLU(True),
View((-1, 256*1*1)), # B, 256
nn.Linear(256, z_dim*2), # B, z_dim*2
)
When I go to start training I call my network to return mu, log variable for reparameterizing after every iteration like so:
x_recon, mu, logvar = self.net(x)
When I do this, I’m getting the above error. Changing nc to 8 results in the same error. I want to keep these images as 8 channels for now, and continue to do 2d convolutions on them. Is there an easy way to do this?
I’m considering doing 3d convolutions later on, and perhaps you could answer how to input that image as a 3-dimensional image as well, opposed to a 8-channel image?
Thanks in advance.