官术网_书友最值得收藏!

Creating data for our neural network

The get_data function in our first neural network code creates two variables, x and y, of sizes (17, 1) and (17). We will take a look at what happens inside the function:

def get_data():
train_X = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,2.167,
7.042,10.791,5.313,7.997,5.654,9.27,3.1])
train_Y = np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,1.221,
2.827,3.465,1.65,2.904,2.42,2.94,1.3])
dtype = torch.FloatTensor
X = Variable(torch.from_numpy(train_X).type(dtype),requires_grad=False).view(17,1)
y = Variable(torch.from_numpy(train_Y).type(dtype),requires_grad=False)
return X,y

主站蜘蛛池模板: 连城县| 西安市| 永登县| 北流市| 吕梁市| 通海县| 光山县| 华池县| 蓬安县| 时尚| 团风县| 定州市| 恩施市| 德令哈市| 兴化市| 察哈| 温州市| 进贤县| 砚山县| 阳朔县| 湄潭县| 精河县| 涞水县| 清河县| 鸡泽县| 宿迁市| 宁海县| 文登市| 盖州市| 寻甸| 延川县| 忻城县| 屏山县| 铜鼓县| 霸州市| 郯城县| 霍州市| 柳林县| 潞西市| 卢氏县| 孟连|