Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: Target dimensionality must be (out_channels, ?,(input_height - filter_height + 2 * padding_height) / stride_height + 1,(input_width - filter_width + 2 * padding_width) / stride_width + 1 #5

Open
tehreemnaqvi opened this issue May 8, 2020 · 7 comments

Comments

@tehreemnaqvi
Copy link

Hi,
I am following your examples.I wanted to use convolutional layers in SNN. So, I followed your examples,which you have done for mnist.Currently, I am working on (two_conv.py) this code.
But i have some issue,when i run this code,got this error.
AssertionError: Target dimensionality must be (out_channels, ?,(input_height - filter_height + 2 * padding_height) / stride_height + 1,(input_width - filter_width + 2 * padding_width) / stride_width + 1
Although i changed this conv_layer_ = DiehlAndCookNodes(
n=n_filters * total_conv_size, shape=(1, n_filters, *conv_size), refrac=0, traces=True, theta_decay=5e-1
)
by
conv_layer_ = DiehlAndCookNodes(
n=n_filters * total_conv_size, shape=(n_filters, conv_size,conv_size), refrac=0, traces=True, theta_decay=5e-1
)
But i got error that non-int tuples can't be multiply.
Please tell how can i fix this issue.
Thanks

@tehreemnaqvi
Copy link
Author

When I changed the shape of output channels, i got this error.
n=n_filters * conv_size * conv_size, shape=(n_filters, conv_size, conv_size),
TypeError: can't multiply sequence by non-int of type 'tuple'

@ferqui
Copy link

ferqui commented May 9, 2020

In the two_conv.py code the variable conv_size is a kernel size tuple, so when you multiply it by n_filters it produces an error. before you define the network certain variables are defined, including total_conv_size = int(np.prod(conv_size)), which is the product of the conv_size dimensions. Try to change n=n_filters * conv_size * conv_size by n=n_filters * total_conv_size

@tehreemnaqvi
Copy link
Author

tehreemnaqvi commented May 9, 2020

First, I tried this but again got same error.
I changed like this:
conv_layer = DiehlAndCookNodes(
n=n_filters * total_conv_size, shape=(1, n_filters, *conv_size),
thresh=-64.0, traces=True, theta_plus=0.05, refrac=0
)
conv_layer_ = DiehlAndCookNodes(
n=n_filters * total_conv_size, shape=(1,n_filters, *conv_size), refrac=0, traces=True, theta_decay=5e-1
)
Error:
line 147, in

AssertionError: Target dimensionality must be (out_channels, ?,(input_height - filter_height + 2 * padding_height) / stride_height + 1,(input_width - filter_width + 2 * padding_width) / stride_width +
Error1

@ferqui
Copy link

ferqui commented May 9, 2020

Hi, the problem now cames in how the internal code of Conv2dConnection get the dimensions of the connection. If we analyze it, we can see that the first parameter of the shape is the number of feature maps of the input layer, then the high and finally the width, so the shape of the input layer should be shape=(1, 28, 28). The same happens with the conv_layer and conv_layer_prime, their shapes should be shape=(n_filters, *conv_size)

@tehreemnaqvi
Copy link
Author

Yeah you are right.I checked all these but got same error.
When I saw the documentation of BindsNet, they had the same error like me.
That's why I am confused how this issued can be fixed.
Thanks

@dee0512
Copy link
Member

dee0512 commented May 10, 2020

Hi @tehreemnaqvi It seems like your error might be due to the addition of mini-batches in bindsnet. Unfortunately, we do not maintain the experiments repo. It is just a place to keep all our experiments.
However, the error you get is due to this line:

https://github.com/BINDS-LAB-UMASS/bindsnet/blob/58c6eb00f7712d9ec2e0ce317a1f73efe2c4cbb8/bindsnet/network/topology.py#L289

Could you log those variables in BindsNET and see what is going wrong?

@wusaifei
Copy link

The main reason is because of con_ layer and con_layer2, shape = (1, n_ filters, *con_ Size) there is a problem. The shape is generally three-dimensional (C, h, w), so delete 1, and finally shape = (n_ filters, *con_ size)

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

No branches or pull requests

4 participants