Comments (14)
The expression "mask>=0.1" returns a tensor of size (1,N), hence the error. Squeeze out the 0th dimension to make it work.
Replace that line with the following line:
of_masked = torch.cat([of_masked[i][(mask>=0.1).squeeze(0)].unsqueeze(0) for i in range(of_masked.size(0))])
from deep-learning.
There was another issue i came across in the function "remap_hist", the following line:
idx = (cum_ref.unsqueeze(1) - rng.unsqueeze(2) < 0).sum(2).long()
It throws an error due to data type mismatch. Typecast tensor 'rng' into a float tensor.
Add the following before the above line:
rng = rng.type(torch.cuda.FloatTensor);
from deep-learning.
@mailcorahul I am getting the following error,Can you please help me with it
/usr/local/lib/python3.6/dist-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
warnings.warn(warning.format(ret))
RuntimeError Traceback (most recent call last)
in ()
1 n_iter=0
----> 2 while n_iter <= max_iter: optimizer.step(partial(step,final_loss))
4 frames
in remap_hist(x, hist_ref)
13 ratio = ratio.squeeze().clamp(0,1)
14 new_x = ymin + (ratio + idx.float()) * step
---> 15 new_x[:,-1] = ymax
16 _, remap = sort_idx.sort()
17 new_x = select_idx(new_x,idx)
RuntimeError: expand(torch.cuda.FloatTensor{[64, 1]}, size=[64]): the number of sizes provided (1) must be greater or equal to the number of dimensions in the tensor (2)
from deep-learning.
This looks like the tensor on which expand is called has a shape of (64, 1), but trying to expand it to size (64), hence the error. From the code you posted I am not able to find out which tensor variable it is, but you can try calling .squeeze() on that tensor(before expand). It should solve it.
from deep-learning.
@mailcorahul im getting error when i try to call the below function
def remap_hist(x,hist_ref):
ch, n = x.size()
sorted_x, sort_idx = x.data.sort(1)
ymin, ymax = x.data.min(1)[0].unsqueeze(1), x.data.max(1)[0].unsqueeze(1)
hist = hist_ref * n/hist_ref.sum(1).unsqueeze(1)#Normalization between the different lengths of masks.
cum_ref = hist.cumsum(1)
cum_prev = torch.cat([torch.zeros(ch,1).cuda(), cum_ref[:,:-1]],1)
step = (ymax-ymin)/n_bins
rng = torch.arange(1,n+1).unsqueeze(0).cuda()
rng = rng.type(torch.cuda.FloatTensor)
idx = (cum_ref.unsqueeze(1) - rng.unsqueeze(2) < 0).sum(2).long()
ratio = (rng - select_idx(cum_prev,idx)) / (1e-8 + select_idx(hist,idx))
ratio = ratio.squeeze().clamp(0,1)
new_x = ymin + (ratio + idx.float()) * step
new_x[:,-1] = ymax
_, remap = sort_idx.sort()
new_x = select_idx(new_x,idx)
return new_x
from deep-learning.
@mailcorahul Hey even I got the same error as @changchethu has faced.Is there any possiblity that u could provide the solution asap..Please..
from deep-learning.
@disharameshh this error is related to tensor shape, please see if my above comment helps.
from deep-learning.
@mailcorahul I went through your above comment......but still I couldn't figure out the piece of code causing the error.....can you be more specific please....can you please tell what part of the code to be changed
from deep-learning.
can you post me the complete exception traceback? i need to know which code statement is throwing error.
from deep-learning.
@mailcorahul
/usr/local/lib/python3.6/dist-packages/torch/nn/_reduction.py:43: UserWarning: size_average and reduce args will be deprecated, please use reduction='sum' instead.
warnings.warn(warning.format(ret))
RuntimeError Traceback (most recent call last)
in ()
1 n_iter=0
----> 2 while n_iter <= max_iter: optimizer.step(partial(step,final_loss))
4 frames
in remap_hist(x, hist_ref)
13 ratio = ratio.squeeze().clamp(0,1)
14 new_x = ymin + (ratio + idx.float()) * step
---> 15 new_x[:,-1] = ymax
16 _, remap = sort_idx.sort()
17 new_x = select_idx(new_x,idx)
RuntimeError: expand(torch.cuda.FloatTensor{[64, 1]}, size=[64]): the number of sizes provided (1) must be greater or equal to the number of dimensions in the tensor (2)
from deep-learning.
It's directing to this function
def remap_hist(x,hist_ref):
ch, n = x.size()
sorted_x, sort_idx = x.data.sort(1)
ymin, ymax = x.data.min(1)[0].unsqueeze(1), x.data.max(1)[0].unsqueeze(1)
hist = hist_ref * n/hist_ref.sum(1).unsqueeze(1)#Normalization between the different lengths of masks.
cum_ref = hist.cumsum(1)
cum_prev = torch.cat([torch.zeros(ch,1).cuda(), cum_ref[:,:-1]],1)
step = (ymax-ymin)/n_bins
rng = torch.arange(1,n+1).unsqueeze(0).cuda()
rng = rng.type(torch.cuda.FloatTensor)
idx = (cum_ref.unsqueeze(1) - rng.unsqueeze(2) < 0).sum(2).long()
ratio = (rng - select_idx(cum_prev,idx)) / (1e-8 + select_idx(hist,idx))
ratio = ratio.squeeze().clamp(0,1)
new_x = ymin + (ratio + idx.float()) * step
new_x[:,-1] = ymax
_, remap = sort_idx.sort()
new_x = select_idx(new_x,idx)
return new_x
from deep-learning.
Can anyone please help me with this issue
from deep-learning.
Can you print the shapes of new_x and ymax before the line "new_x[:,-1] = ymax"?
Post the shapes of both tensors here.
from deep-learning.
@disharameshh in remap_dist function, replace new_x[:,-1] = ymax
withnew_x[:,-1] = ymax.squeeze()
from deep-learning.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-learning.