vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 752 forks source link

Batch size is being confused with kernel depth #1233

Open h612 opened 5 years ago

h612 commented 5 years ago

I'm using GPU to train a Convolutional Deep Neural Network. The batch size is being confused for the kernel depth.

I'm using Matlab 2019a. I've a getBatch function. The images (150x150) are used to estimate density in them. The label images are also same dimensions (150,150). The neural network is expected to estimate density in the input images.


opts.batchSize =64;

function [im1,im2,labels1, labels2] = getBatch(imdb, batch,useGpu)
im1 = imdb.images.data_src1(:,:,:,batch) ;
labels1 = imdb.images.labels1(:,:,:,batch) ;
...
 if useGpu > 0
    im1 = gpuArray(im1) ;        im2 = gpuArray(im2) ;
        labels1=gpuArray(labels1) ;  labels2=gpuArray(labels2) ;
    end

The following is first layer of a network which has 4 kernel depth and input is 'input1'

%First layer of the network
net1.addLayer('conv1', dagnn.Conv('size', [11 11 3 4], 'hasBias', true, 'stride', [1, 1], 'pad', [0 0 0 0]), {'input1'}, {'conv1'},  {'conv1f'  'conv1b'});
 %where 'input1' is 
 function inputs = getBatchDagNN(imdb, batch, useGpu)
 % -------------------------------------------------------------------------

 [im1,im2,labels1, labels2] = getBatch(imdb, batch,useGpu);

 if nargout > 0
   inputs = {'input1', im1,'input2', im2, 'label1', labels1};%, 'label2', labels2} ;
 end

The convolution is not taking place because the error is 'DATA and FILTERS do not have compatible formats.' The filter it sees is 150X150X3X64 Whereas I expect it should have150X150X3X4. Please help me understand what's wrong!