Advertisement

pytorch核心操作流程

阅读量:

1、网络架构的设计与搭建

2、模型的训练过程

3、网络模型及参数的存储操作

4、已存储文件的再次加载

复制代码
 import torch

    
 import matplotlib.pyplot as plt
    
 import numpy as np
    
  
    
 x = torch.unsqueeze(torch.linspace(-1, 1, 100), dim=1)  # x data (tensor), shape=(100, 1)
    
 y = x.pow(2) + x.pow(5) + 0.2*torch.rand(x.size())  # noisy y data (tensor), shape=(100, 1)
    
  
    
  
    
 n_input = 6
    
 n_hidden = 12
    
 n_output = 1
    
  
    
 # 构建网络架构
    
 net1 = torch.nn.Sequential(
    
     torch.nn.Linear(1, 10),
    
     torch.nn.ReLU(),
    
     torch.nn.Linear(10, 1)
    
     )
    
 # 优化器
    
 optimiz

全部评论 (0)

还没有任何评论哟~