import numpy as np lis = [1, 5, -9, 3, -6, 8, -7, 5, 5, 5, 4, 4, 4, 6, 6, 6, 6] lis = np.array(lis) lis[lis <= 0] = 100 print(lis)
[ 1 5 100 3 100 8 100 5 5 5 4 4 4 6 6 6 6]
lis = [1, 5, -9, 3, -6, 8, -7, 5, 5, 5, 4, 4, 4, 6, 6, 6, 6] lis = torch.tensor(lis) lis[lis <= 0] = 100 print(lis)
tensor([ 1, 5, 100, 3, 100, 8, 100, 5, 5, 5, 4, 4, 4, 6,
6, 6, 6])