0
点赞
收藏
分享

微信扫一扫

使用ReLU进行数组的输出

import torch
from torch import nn
from torch.nn import ReLU

input = torch.tensor([[1,-0.5],
                      [-1,3]])
input = torch.reshape(input,(-1,1,2,2))
class Tudui(nn.Module):
    def __init__(self):
        super(Tudui, self).__init__()
        self.relu1 = ReLU()
    def forward(self,input):
        output = self.relu1(input)
        return output
tudui = Tudui()
output = tudui(input)
print(output)

输入,发现负数都变成0了。

tensor([[[[1., 0.],
          [0., 3.]]]])
举报

相关推荐

0 条评论