Hi, I have two tensors the range value of the first tensor is between 5 to 18 and the other tensor is 0.02 to 0.07. How can I change the scale value of the first tensor like the second tensor?

thanks

You could normalize the data first and then shift and scale it to the desired range:

```
x = torch.empty(1000).uniform_(5, 12)
y = (x - 5) / (12 - 5) # normalize to [0, 1]
print(y.min(), y.max())
> tensor(0.0026) tensor(1.0000)
y = (y * (0.07 - 0.02)) + 0.02 # scale to [0.02, 0.07]
print(y.min(), y.max())
> tensor(0.0201) tensor(0.0700)
```

1 Like

Hi ptrblck, thanks for your reply. Actually, I am using a knowledge distillation code where the teacher is Alexnet and the student is a simple network than Alexnet. when I print the last encoding vector of both networks I see a different range of values like 5 to 18 for the teacher and 0.02 to 0.07 for the student network. It makes a problem in my analysis. I confused!