最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

PyTorch Tutorial 12 - Activation Func...

2023-02-16 17:18 作者:Mr-南喬  | 我要投稿

教程Python代碼如下:


import torch

import torch.nn as nn

import torch.nn.functional as F



# option 1 (create nn modules)

class NeuralNet(nn.Module):

def __init__(self, input_size, hidden_size):

super(NeuralNet, self).__init__()

self.linear1 = nn.Linear(input_size, hidden_size)

self.relu = nn.ReLU()

self.linear2 = nn.Linear(hidden_size, 1)

self.sigmoid = nn.Sigmoid()

def forward(self, x):

out = self.linear1(x)

out = self.relu(out)

out = self.linear2(out)

out = self.sigmoid(out)

return out


# option 2 (use activation functions directly in forward pass)

class NeuralNet(nn.Module):

def __init__(self, input_size, hidden_size):

super(NeuralNet, self).__init__()

self.linear1 = nn.Linear(input_size, hidden_size)

self.linear2 = nn.Linear(hidden_size, 1)

def forward(self, x):

out = torch.relu(self.linear1(x))

out = torch.sigmoid(self.linear2(out))

return out

PyTorch Tutorial 12 - Activation Func...的評論 (共 條)

分享到微博請遵守國家法律
西城区| 定州市| 石渠县| 吐鲁番市| 鄱阳县| 嘉义市| 磐安县| 拉萨市| 嘉荫县| 东安县| 巴中市| 子长县| 昌平区| 永丰县| 和平县| 旬邑县| 马公市| 汉沽区| 嵊州市| 横峰县| 西峡县| 咸丰县| 桐柏县| 潜江市| 茌平县| 浦江县| 沾化县| 连城县| 将乐县| 全椒县| 丹阳市| 安溪县| 图们市| 溧水县| 庄河市| 定兴县| 庆城县| 潮州市| 浦城县| 南开区| 阿克陶县|