As a list of basis functions when doing linear radial basis regression
bases = [lambda x: (torch.exp(-((x[..., 0] - x_mean)/std_x) ** 2 - ((x[..., 1] - dx_mean)/std_dx) ** 2))
for x_mean in np.linspace(start=-1., stop=1., num=10)
for dx_mean in np.linspace(start=-1., stop=1., num=10)
]
But I ended up with the same list of functions.
Think of a simple example
f = [lambda x: print(i) for i in range(4)]
Then the value of the variable $ i $ at runtime of the lambda statement is used, For any n
f[n](10) = 3
Will be.
To use the variable value at the time of definition,
f = [lambda x, s=i: print(s) for i in range(4)]
You can use the default arguments like this
Recommended Posts