莫凡pytorch
https://yulizi123.github.io/learning-steps/
篱下浅歌生
这个作者很懒,什么都没留下…
展开
-
RNN模型
文章目录一、代码二、实现效果 #RNN模型 一、代码 import torch import torch.nn as nn x_input = torch.randn(2,3,10) class RNN(nn.Module): def __init__(self,input_size,hidden_size,batch_first=False): super(RNN,self).__init__() self.rnn_cell = nn.RNNCell(inp原创 2022-01-29 22:00:23 · 1001 阅读 · 0 评论 -
Bert使用
文章目录Bert一、代码二、实现效果 Bert 一、代码 import torch from transformers import BertModel,BertTokenizer import torch.nn as nn sentence = ‘i like eating apples very much’ class Model (nn.Module): def init(self): super().init() self.embeder = BertModel.from_pretrained原创 2022-01-28 22:20:04 · 635 阅读 · 0 评论 -
RNN实现回归模型
文章目录RNN实现回归模型一、代码 RNN实现回归模型 用 sin 的曲线预测出 cos 的曲线. 一、代码 """ View more, visit my tutorial page: https://mofanpy.com/tutorials/ My Youtube Channel: https://www.youtube.com/user/MorvanZhou Dependencies: torch: 0.4 matplotlib numpy """ import torch from torch原创 2022-01-15 15:18:07 · 816 阅读 · 0 评论 -
RNN实现MNIST手写数据识别
文章目录RNN实现MNIST手写数据识别一、代码二、实现效果 RNN实现MNIST手写数据识别 一、代码 import torch import torchvision.datasets from torch import nn import torch.utils.data as Data EPOCH=1 #训练多少次 BATCH_SIZE =64 #批训练数量 TIME_STEP=28 #nn时间步数/图片高度 INPUT_SIZE=28 #nn每步输入值/图片每行像素 LR=0.01 #学习率 D原创 2022-01-15 14:49:40 · 870 阅读 · 0 评论 -
CNN实现MNIST手写数据识别
文章目录CNN实现MNIST手写数据识别一、代码二、实现效果 CNN实现MNIST手写数据识别 一、代码 # library # standard library import os # third-party library import torch import torch.nn as nn import torch.utils.data as Data import torchvision import matplotlib.pyplot as plt # torch.manual_seed(1原创 2022-01-14 22:11:29 · 286 阅读 · 0 评论 -
pytorch实现回归模型
文章目录pytorch实现回归模型一、代码二、实现效果 pytorch实现回归模型 一、代码 import torch import torch.nn.functional as F import matplotlib.pyplot as plt #建立数据集 x = torch.unsqueeze(torch.linspace(-1,1,100),dim=1)# x data(tensor),shape(100,1) y = x.pow(2) + 0.2*torch.rand(x.size())#原创 2021-12-14 21:47:11 · 2504 阅读 · 0 评论