PyTorch_8_神经网络的基本骨架-nn_Module的使用


from typing import Any

import torch
from torch import nn


class TuDui(nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, input):
        output = input + 1
        return output

tudui = TuDui()
x = torch.tensor(1.0)
output = tudui(x)
print(output)

Author: Ruimin Huang
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint polocy. If reproduced, please indicate source Ruimin Huang !
  TOC