DeepFeatureExtractor features not compatible with ConvolutionNet?

User 5340 | 7/14/2016, 7:42:59 PM

Hi,

I tried building an image classifier with a graphlab ConvolutionNet and use features extracted via the DeepFeatureExtractor (letting it choose the best pre-trained model). The features were created successfully, and I can use them without a problem in a regular neural net classifier, but with the conv net I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/graphlab/toolkits/classifier/neuralnet_classifier.py", line 942, in create
    raise ValueError(e.message + "\n" + msg)
ValueError: Layer 0: Cannot convolve or pool flattened inputs.
The input network is valid, but is not compatible with the input and output shape of the dataset.
Please change the network and use net.verify() with input_shape=[1, 1, 4096], and output_shape=5

Do I need to add another layer to the conv net? The conv net looks like this:

### network layers ###
layer[0]: ConvolutionLayer
  init_random = gaussian
  padding = 0
  stride = 2
  num_channels = 10
  num_groups = 1
  kernel_size = 3
layer[1]: MaxPoolingLayer
  padding = 0
  stride = 2
  kernel_size = 3
layer[2]: ConvolutionLayer
  init_random = gaussian
  padding = 0
  stride = 2
  num_channels = 10
  num_groups = 1
  kernel_size = 3
layer[3]: MaxPoolingLayer
  padding = 0
  stride = 2
  kernel_size = 3
layer[4]: ConvolutionLayer
  init_random = gaussian
  padding = 0
  stride = 2
  num_channels = 10
  num_groups = 1
  kernel_size = 3
layer[5]: MaxPoolingLayer
  padding = 0
  stride = 2
  kernel_size = 3
layer[6]: FlattenLayer
layer[7]: FullConnectionLayer
  init_sigma = 0.01
  init_random = gaussian
  init_bias = 0
  num_hidden_units = 5
layer[8]: SoftmaxLayer
### end network layers ###

Thanks, Beata

Comments

User 940 | 7/18/2016, 6:46:14 PM

Hi Beata,

Convolutional Neural nets take as input an image type, whereas extracted features are of array type. You theoretically could use the .pixelarraytoimage()(https://turi.com/products/create/docs/generated/graphlab.SArray.pixelarraytoimage.html#graphlab.SArray.pixelarrayto_image) function to convert between the two, but this doesn't really make sense in this case. The operation of convolution depends on adjacent inputs not being independent of each other...for instance that adjacent pixels belong to the same object. This doesn't hold true for extracted features since any spatial dependence is 'scrambled' by fully connected layers. For more about convolution, a good resource is http://cs231n.github.io/convolutional-networks/#conv.

With that out of the way, what is your use case? Maybe we can provide some pointers.

I hope this helps.

Cheers! -Piotr