Advertisement

MXNet与 gluon 的学习笔记:线性回归模型

阅读量:

依据李沐所提供的课程资料与教科书内容,对关键部分进行了注解说明

1. ndarray实现

复制代码
 %matplotlib inline

    
 from IPython import display
    
 from matplotlib import pyplot as plt
    
 from mxnet import autograd, nd
    
 import random
    
  
    
 # 本函数已保存在 gluonbook 包中方便以后使用。
    
 def data_iter(batch_size, features, labels):
    
     num_examples = len(features)
    
     indices = list(range(num_examples))
    
     #print('indices=',indices)
    
     random.shuffle(indices)  # 样本的读取顺序是随机的。
    
     for i in range(0, num_examples, batch_size):
    
     j = nd.array(indices[i: min(i + batch_size, num_examples)])

全部评论 (0)

还没有任何评论哟~