- Deep Learning with PyTorch
- Vishnu Subramanian
- 116字
- 2021-06-24 19:16:25
Creating learnable parameters
In our neural network example, we have two learnable parameters, w and b, and two fixed parameters, x and y. We have created variables x and y in our get_data function. Learnable parameters are created using random initialization and have the require_grad parameter set to True, unlike x and y, where it is set to False. There are different practices for initializing learnable parameters, which we will explore in the coming chapters. Let's take a look at our get_weights function:
def get_weights():
w = Variable(torch.randn(1),requires_grad = True)
b = Variable(torch.randn(1),requires_grad=True)
return w,b
Most of the preceding code is self-explanatory; torch.randn creates a random value of any given shape.
推薦閱讀
- Instant uTorrent
- 電腦維護與故障排除傻瓜書(Windows 10適用)
- 硬件產品經理手冊:手把手構建智能硬件產品
- Large Scale Machine Learning with Python
- 單片機系統設計與開發教程
- 面向對象分析與設計(第3版)(修訂版)
- Building 3D Models with modo 701
- Neural Network Programming with Java(Second Edition)
- 圖解計算機組裝與維護
- Arduino項目案例:游戲開發
- The Applied Artificial Intelligence Workshop
- 分布式存儲系統:核心技術、系統實現與Go項目實戰
- 從企業級開發到云原生微服務:Spring Boot實戰
- The Machine Learning Workshop
- 計算機組裝與維護