How to ensure each element in a tensor with random dimensions above the threshold?

Before posting a query, check the FAQs - it might already be answered!

Hi, I wanted to make sure each element inside the tensor is above the thredshold,

for example, t = torch.rand(2, 3), if any each t[i][j] <0.1, i want it be be 0.1.

How to do that?

Just set a threshold value and apply mask in the index.

t = th.rand(2, 3)
threshlold=# Define your threshold
t[t < threshold] = #your value

This should do the job.