import numpy as np x=np.random.randn(1000,2) w=np.array([[1],[2]]) b=-3 y=x*w+b print(y)
时间: 2024-05-19 15:13:26 浏览: 88
Numpy中np.random.rand()和np.random.randn() 用法和区别详解
As an AI language model, I cannot execute code or print output here. However, I can explain what the code does.
The code generates a 2-dimensional NumPy array `x` of shape `(1000, 2)` with random values drawn from a standard normal distribution. It also creates a weight vector `w` of shape `(2, 1)` with values `[1, 2]` and a bias term `b` of value `-3`.
Then, it performs a matrix multiplication between `x` and `w` (i.e., `y = x * w`) and adds the bias term `b` to each element of the resulting array `y`. The final result `y` is a 1-dimensional NumPy array of shape `(1000,)` with the dot product of each row of `x` with `w`, plus `b`.
阅读全文