- Deep Learning with PyTorch
- Vishnu Subramanian
- 61字
- 2021-06-24 19:16:25
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
推薦閱讀
- 零點起飛學Xilinx FPG
- 深入理解Spring Cloud與實戰
- Learning Cocos2d-x Game Development
- 電腦維護與故障排除傻瓜書(Windows 10適用)
- 嵌入式系統中的模擬電路設計
- OUYA Game Development by Example
- 電腦高級維修及故障排除實戰
- 無蘋果不生活:OS X Mountain Lion 隨身寶典
- Mastering Machine Learning on AWS
- 基于網絡化教學的項目化單片機應用技術
- Istio實戰指南
- Mastering Quantum Computing with IBM QX
- 微服務實戰
- 計算機組成技術教程
- 嵌入式系統設計大學教程(第2版)