Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

AssertionError in convolutional layer when number of channels is not a multiple of 4 #257

Closed
Maratyszcza opened this issue Jun 13, 2016 · 3 comments
Milestone

Comments

@Maratyszcza
Copy link

I'm trying to train a convolutional network where one convolutional layer has unusual number of output channels, and get an assertion on Titan X GPU with F32 precision

  File "convmodel.py", line 94, in <module>
    model.fit(train, optimizer=opt, num_epochs=args.epochs, cost=cost, callbacks=callbacks)
  File "/home/adience/neon/neon/models/model.py", line 141, in fit
    self.initialize(dataset, cost)
  File "/home/adience/neon/neon/models/model.py", line 100, in initialize
    prev_input = self.layers.configure(prev_input)
  File "/home/adience/neon/neon/layers/container.py", line 140, in configure
    in_obj = l.configure(in_obj)
  File "/home/adience/neon/neon/layers/layer.py", line 657, in configure
    self.nglayer = self.be.conv_layer(self.be.default_dtype, **self.convparams)
  File "/home/adience/neon/neon/backends/nervanagpu.py", line 1636, in conv_layer
    relu, bsum)
  File "/home/adience/neon/neon/backends/layer_gpu.py", line 469, in __init__
    pad_d, pad_h, pad_w, str_d, str_h, str_w, relu, bsum)
  File "/home/adience/neon/neon/backends/convolution.py", line 119, in __init__
    assert K % self.vec_size == 0, "K dim must be multiple of %d" % self.vec_size
AssertionError: K dim must be multiple of 4

If I try to train in F16 precision, the error is AssertionError: K dim must be multiple of 8. If I try to train on CPU, there is no error (but training is unbearably slow).

@scott-gray
Copy link
Collaborator

That restriction has been lifted in newer kernels. These will be released in a week or so. In the meantime you should be able to pad out your K dim to a multiple of 4.

@Maratyszcza
Copy link
Author

Thanks for prompt response! Padding K wouldn't work for my use-case: its a fully convolutional network with uneven number of categories. Looking forward to the next release!

@ursk
Copy link
Contributor

ursk commented Jun 14, 2016

You can still pad K and leave the extra categories empty. You just have to make the corresponding change to the dataset, e.g. if you are using ArrayIterator, pass in the nclass argument with the padded number of categories.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants