‘Criterion’ object has no attribute ‘cuda’!
Hello there, I wrote  below customized Cost Function for my project: My codes to benefit from these written cost are: Thanks!
mderakhshani
calling torch.FloatTensor will always put your tensor in the CPU. You probably want to get the device in which the input tensor is by doing something like pred_out.new(), which will generate a new tensor in the same device as pred_out. you are using np.ndarray in parts of your code. While it’s possible to do it, it will avoid parts of your code to run in the GPU Performing for loops for the computations that you want will probably be slower in the GPU than in the CPU. You’d probably want to wrap some inner loops using only batched mathematical operations in tensors so that it can be efficiently computed in the GPU, so that instead of accepting one bounding box, you accept a bunch of them at the same time.
fmassa
mderakhshani
<SCODE>output = output.cpu()
loss = criterion(output, target)
<ECODE> and that should work out of the box.
fmassa