ShusenTang / Dive-into-DL-PyTorch

本项目将《动手学深度学习》(Dive into Deep Learning)原书中的MXNet实现改为PyTorch实现。
http://tangshusen.me/Dive-into-DL-PyTorch
Apache License 2.0
18.41k stars 5.4k forks source link

There is a line of redundant code in 7.3.1 #153

Open qiujunlin opened 4 years ago

qiujunlin commented 4 years ago

bug描述 描述一下你遇到的bug, 例如报错位置、报错信息(重要, 可以直接截个图)等

版本信息 pytorch: torchvision: torchtext: ... %matplotlib inline import numpy as np import time import torch from torch import nn, optim import sys sys.path.append("..") import d2lzh_pytorch as d2l

def get_data_ch7(): # 本函数已保存在d2lzh_pytorch包中方便以后使用 data = np.genfromtxt('../../data/airfoil_self_noise.dat', delimiter='\t') data = (data - data.mean(axis=0)) / data.std(axis=0) return torch.tensor(data[:1500, :-1], dtype=torch.float32), \ torch.tensor(data[:1500, -1], dtype=torch.float32) # 前1500个样本(每个样本5个特征)

features, labels = get_data_ch7() features.shape # torch.Size([1500, 5])