I want to train a simple linear model. these below x and y are my data.
import numpy as np
x = np.linspace(0,1,100)
y = 2 * x + 3 + np.random.randn(100)
f is a function that calculates mean square error over all data.
def f(params, x, y):
return np.mean(np.power((params['w'] * x + params['b'])-y , 2))
from jax import grad
df = grad(f)
params = dict()
#initialize parameters
params['w'] = 2.4
params['b'] = 10.
df(params, x, y) # I will do this in a loop (implementing gradient decent part
this gives me an error:
FilteredStackTrace: jax._src.errors.TracerArrayConversionError: The numpy.ndarray conversion method __array__() was called on the JAX Tracer object Traced<ConcreteArray
when I clear np.power code works. why?