How Should I Feed my Gradient Descent?

Photo by Jonathan Farber on Unsplash



# Setting the seed

# Creating observations
X_train = np.random.rand(number_of_observations,number_of_features)
X_valid = np.random.rand(number_of_observations,number_of_features)

# Instantiating the parameters W and b
W = np.round(np.random.rand(number_of_features,1)*10, 0)
b = np.round(np.random.rand(1,1),0)

# Creating some noise
noise = np.random.randn(number_of_observations,1)

# Creating y by doing XW + b and some noise
y_train =, W) + b + noise
y_valid =, W) + b + noise

# Printing coefficients
print(f"True W: {W[0][0]} \nTrue b: {b[0][0]}")





Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store