Last active
August 13, 2024 23:48
-
-
Save andreh7/74221b7140594d1f8062788729a62524 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your article is a great teaching moment - but I have run into issues running your code as is - specifically during training:
starting training
IndexError Traceback (most recent call last)
in ()
47 input_var = Variable(torch.from_numpy(this_inputs))
48
---> 49 output = model.forward(input_var)
50
51 # build a PyTorch variable with the target value
in forward(self, input)
40 input = input.data.numpy()
41
---> 42 return self.single_coord_func(input[:,0], 0) + self.single_coord_func(input[:,1], 1)
in single_coord_func(self, input, coord)
24 # fold in underflow/overflow bins
25 indices = np.clip(indices, 0, self.n_bins_xy[coord] - 1)
---> 26 return torch.cat([ self.coeffs[indices[row], coord] for row in range(len(input)) ])
27
28 #----------------------------------------
in (.0)
24 # fold in underflow/overflow bins
25 indices = np.clip(indices, 0, self.n_bins_xy[coord] - 1)
---> 26 return torch.cat([ self.coeffs[indices[row], coord] for row in range(len(input)) ])
27
28 #----------------------------------------
IndexError: only integers, slices (
:
), ellipsis (...
), None and long or byte Variables are valid indices (got numpy.float32)