B站小土堆視頻學(xué)習(xí)筆記
官網(wǎng)Module介紹
https://pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module
Python父類子類繼承關(guān)系
https://www.php.cn/faq/555151.html
前向神經(jīng)網(wǎng)絡(luò)
前向傳播
與之對應(yīng)的還有反向傳播
推薦課程
吳恩達(dá)卷積
李宏毅深度學(xué)習(xí) cnn
同濟(jì)子豪兄神經(jīng)網(wǎng)絡(luò)
pycharm快捷鍵重寫類方法
code–>Generate–>override Methods–>init 重寫init方法
code
import torch
from torch import nn
class my_neural_network(nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
output = input + 1
return output
my_net = my_neural_network()
# x = torch.Tensor(1.0) # TypeError: new(): data must be a sequence (got float)
x = torch.tensor(1.0)
output = my_net(x)
print(output)
debug
torch.tensor和torch.Tensor的區(qū)別
torch.tensor是方法,可以將參數(shù)轉(zhuǎn)換為tensor數(shù)據(jù)類型,輸入可以是序列【列表】、元組、ndarray,也可以是單獨一個數(shù)等多種數(shù)據(jù)類型
torch.Tensor是一個類 輸入?yún)?shù)需要是一個序列比如列表文章來源:http://www.zghlxwxcb.cn/news/detail-696400.html
https://blog.csdn.net/qq_36930266/article/details/104602792文章來源地址http://www.zghlxwxcb.cn/news/detail-696400.html
到了這里,關(guān)于學(xué)習(xí)pytorch7 神經(jīng)網(wǎng)絡(luò)的基本骨架--nn,module的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!