from mxnet import nd
from time import time
a = nd.ones(shape=1000)
b = nd.ones(shape=1000)
start = time()
c = nd.zeros(shape=1000)
for i in range(1000):
c[i] = a[i]+b[i]
time() - start
start = time()
d = a + b
time() - start
a = nd.ones(shape=3)
b = 10
a + b
#代码从这里开始,上面是简单的练习----------------------------------------------------------
%matplotlib inline
from IPython import display
from matplotlib import pyplot as plt
from mxnet import autograd, nd
import random
num_inputs = 2
num_examples = 1000
true_w = [2, -3.4]
true_b = 4.2
features = nd.random.normal(scale=1,shape=(num_examples, num_inputs))
labels = true_w[0] * features[:,0] + true_w[1] * features[:,1] + true_b
labels += nd.random.normal(scale=0.01, shape=labels.shape)
features[0],labels[0]
def use_svg_display():
# 用矢量图显示
display.set_matplotl
线性回归(2)从零开始实现
最新推荐文章于 2024-07-14 18:19:25 发布
本文深入探讨线性回归的基本概念,并逐步引导读者从零开始实现一个简单的线性回归模型。通过理解线性回归的数学原理,我们将亲自编写代码,完成模型训练与预测,为后续的机器学习实践奠定基础。
摘要由CSDN通过智能技术生成