![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
corc++
这个作者很懒,什么都没留下…
展开
-
dataset读取方式二
import torchvision.datasets as datasetsfrom torchvision import transforms,utilsfrom torch.utils.data import dataloader,DataLoadertrans = transforms.Compose([transforms.ToTensor(),transforms.Resize((48,48))])data = datasets.ImageFolder(root=r'E:\pyth原创 2022-05-04 21:03:45 · 105 阅读 · 0 评论 -
dataset图像加载和显示
在这里插入代码################dataset1111111#########################import torchimport osfrom torch.utils.data import Dataset ,DataLoaderfrom torch import nn as nnfrom torchvision import transformsimport numpy as npfrom PIL import Imageimport cv2c原创 2022-05-04 20:39:01 · 241 阅读 · 0 评论 -
dataset数据集读取 ----1
class Mydataset(Dataset): def __init__(self,fliepatch ,lablespatch ,transfrom =None ): self.trans = transfrom self.images = [] self.classes = [] subist= os.listdir(fliepatch) for i in subist: self.原创 2022-05-04 16:35:56 · 530 阅读 · 0 评论 -
torch.cat()函数 dim = 2 和 -1 时关于第三维度的拼接。不理解的可问
import torchc = torch.randn((2,3,4))d = torch.randn((2,3,4))print(c,d)print(c.shape,d.shape)print(torch.cat((c,d),dim=0))print(torch.cat((c,d),dim=1))print(torch.cat((c,d),dim=2))m = torch.cat((c,d),dim=0)n = torch.cat((c,d),dim=1)l = torch.cat(原创 2022-03-29 14:39:07 · 3892 阅读 · 1 评论 -
vgg-16自复现
```pythonimport torchimport torch.nn as nnimport torch.nn.functional as Fclass conv1(nn.Module): def __init__(self , inchannel ,outchannel): super(conv1, self).__init__() self.conv1 = nn.Sequential( nn.Conv2d(in_cha.原创 2022-03-13 18:33:20 · 160 阅读 · 0 评论 -
inception-v1 自复现 有问题尽管问
代码:import torchimport torch.nn as nnimport torch.nn.functional as Fclass inceptionModuleV1(nn.Module): def __init__(self,inputs, outputs1 , outputs2 ,outputs3 ,outputs4 ,outputs5 ,outputs6): super(inceptionModuleV1,self).__init__()原创 2022-03-13 10:30:01 · 90 阅读 · 0 评论 -
自复现的alexnet模型,学习记录,有疑问请指出
```pythonimport torchimport torch.nn as nnimport torch.nn.functional as Fclass ALX(nn.Module): def __init__(self): self.conv1 = nn.Conv2d(in_channels=3 ,out_channels= 96 ,kernel_size= 11 ,stride= 4 ,padding= 0) self.maxpool =.原创 2022-03-10 18:40:19 · 166 阅读 · 0 评论 -
AI-openpose,肢体识别,预训练模型,mobilenet_sgd_68.848.pth.tar
我就不上传csdn了,下载需要花钱。有需要的可以私信我。原创 2022-03-03 10:16:46 · 696 阅读 · 43 评论 -
Rnn ,沐神
这里 我就直接上代码了 ,因为沐神的是分开的 ,我调试放到了一起,`import torchimport randomimport zipfilefrom acem.utils import *device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')print(torch.__version__)print(device)## with zipfile.ZipFile('./jaychou_lyrics.t原创 2021-11-30 19:31:59 · 172 阅读 · 0 评论 -
2021-10-18
import torchx_da = [1.0,2.0,3.0]y_da = [2.0,4.0,6.0]w = torch.Tensor([1.0])w.requires_grad = Truedef forward(x): return w * xdef loss(x , y): return (forward(x) - y)**2epoc = []costs = []for epo in range(100): for xs, ys in z..原创 2021-10-18 16:01:22 · 86 阅读 · 0 评论 -
mnist识别模型生成,加识别代码。
import torchfrom torchvision import transformsfrom torchvision import datasetsfrom torch.utils.data import DataLoaderimport torch.nn.functional as F #reluimport torch.optim as optimbatch_size = 64transform = transforms.Compose([transforms.ToTen原创 2021-10-15 23:28:50 · 101 阅读 · 0 评论 -
pytorch Tensor和tensor张量变换差异----Found dtype Long but expected Float:刘二
import torchx_data = torch.tensor([[1.0],[2.0],[3.0]])y_data = torch.tensor([[5.0],[6.0],[7.0]])class LinerModel(torch.nn.Module): def __init__(self): super(LinerModel,self).__init__() self.lin = torch.nn.Linear(1,1) def fo原创 2021-10-14 13:53:40 · 470 阅读 · 0 评论 -
pytorch线性模型 刘二
代码如下:import torchx_data = torch.tensor([[1.0],[2.0],[3.0]])y_data = torch.tensor([[2.0],[4.0],[6.0]])class Linear(torch .nn.Module): def __init__(self): super(Linear,self).__init__() self.linear = torch.nn.Linear(1,1)原创 2021-10-14 00:20:39 · 65 阅读 · 0 评论 -
2021-10-13
PyTorch反向传播学习实例(p4)刘二import torchx_da = [1.0,2.0,3.0]y_da = [2.0,4.0,6.0]w1 = torch.tensor([1.0])w1.requires_grad= Truew2= torch.tensor([1.0])w2.requires_grad=Trueb = torch.tensor([1.0])b.requires_grad=Truedef dors(x): return w1 *x *x + w原创 2021-10-13 09:43:36 · 72 阅读 · 1 评论