dimensions

How to calculate dimensions of first linear layer of a CNN

How to calculate dimensions of first linear layer of a CNN Question: Currently, I am working with a CNN where there is a fully connected layer attached to it and I am working with a 3 channel image of size 32×32. I am wondering on if there is a consistent formula I can use to …

Total answers: 2

What does -1 mean in pytorch view?

What does -1 mean in pytorch view? Question: As the question says, what does -1 do in pytorch view? >>> a = torch.arange(1, 17) >>> a tensor([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12., 13., 14., 15., 16.]) >>> a.view(1,-1) tensor([[ 1., 2., 3., 4., 5., 6., 7., 8., 9., …

Total answers: 6

Swapping the dimensions of a numpy array

Swapping the dimensions of a numpy array Question: I would like to do the following: for i in dimension1: for j in dimension2: for k in dimension3: for l in dimension4: B[k,l,i,j] = A[i,j,k,l] without the use of loops. In the end both A and B contain the same information but indexed differently. I must …

Total answers: 5

Numpy array dimensions

Numpy array dimensions Question: How do I get the dimensions of an array? For instance, this is 2×2: a = np.array([[1,2],[3,4]]) Asked By: morgan freeman || Source Answers: Use .shape to obtain a tuple of array dimensions: >>> a.shape (2, 2) Answered By: Felix Kling import numpy as np >>> np.shape(a) (2,2) Also works if …

Total answers: 9