pytorch

RuntimeError: size mismatch, m1: [4 x 3136], m2: [64 x 5] at c:\a\w\1\s\tmp_conda_3.7_1

妖精的绣舞 提交于 2021-02-02 09:09:42
问题 I used python 3 and when i insert transform random crop size 224 it gives miss match error. here my code what did i wrong ? 回答1: Your code makes variations on resnet: you changed the number of channels, the number of bottlenecks at each "level", and you removed a "level" entirely. As a result, the dimension of the feature map you have at the end of layer3 is not 64: you have a larger spatial dimension than you anticipated by the nn.AvgPool2d(8). The error message you got actually tells you

RuntimeError: size mismatch, m1: [4 x 3136], m2: [64 x 5] at c:\a\w\1\s\tmp_conda_3.7_1

匆匆过客 提交于 2021-02-02 09:09:37
问题 I used python 3 and when i insert transform random crop size 224 it gives miss match error. here my code what did i wrong ? 回答1: Your code makes variations on resnet: you changed the number of channels, the number of bottlenecks at each "level", and you removed a "level" entirely. As a result, the dimension of the feature map you have at the end of layer3 is not 64: you have a larger spatial dimension than you anticipated by the nn.AvgPool2d(8). The error message you got actually tells you

使用谷歌Colab Notebooks,这6个小技巧你需要掌握

允我心安 提交于 2021-01-31 11:11:27
选自Medium 作者:Iden W.机器之心编译 编辑:陈萍、杜伟 转载自: 机器之心 原文链接: 使用谷歌Colab Notebooks,这6个小技巧你需要掌握 ​ mp.weixin.qq.com 切换暗黑模式、读取 CSV 文件… 这些非常实用的小技巧为开发者使用谷歌 Colab Notebooks 提供了便利。 Google Colab 给广大的 AI 爱好者和开发者提供了免费的 GPU,他们可以在上面轻松地跑 Tensorflow、PyTorch 等深度学习框架。特别地,Colab 实时 Notebooks 在数据共享方面为广大开发者提供了便利,通过链接即可与其他的开发者共享文件。 在本文中,数据科学家 Iden W. 为读者详细地介绍了使用 Google Colab Notebooks 的小技巧,主要包括以下几个方面: 切换暗黑模式 读取 CSV 文件 栈溢出的快捷方式 启动内核 提交至 GitHub 存储库并共享 分享 Google Colab Notebooks 切换暗黑模式 如果开发者想使用 Google Colab 的暗黑模式,请点击「Tools」选项卡,然后按照下图所示的步骤进行设置。 在「settings」中,你可以单击「Site」菜单,然后选择「dark」功能,单击保存。操作完成后即可切换暗黑模式。 读取 CSV 文件 从 Google Drive

Hinton最新访谈:无监督胶囊网络、对比学习以及大脑中的反向传播

走远了吗. 提交于 2021-01-30 11:53:00
来源 | 数据实战派 转载自:AI科技评论 原文链接: Hinton最新访谈:无监督胶囊网络、对比学习以及大脑中的反向传播 ​ mp.weixin.qq.com Geoff Hinton 是公认的深度学习先驱。2018 年,他与 Yoshua Bengio、Yann LeCun 共同获得了图灵奖。而在这之前的一年,他提出了一个想法 —— 胶囊网络(Capsule Network)。这是卷积神经网络的替代方案,它考虑了物体在 3D 世界中的姿势,尝试弥补当今计算机视觉模型学习能力上的不足,比如学会从不同的角度来识别同一个物体。 从那之后, Hinton 在学术界的公开活动有所沉寂。直到2020 年 12 月,在 NeurIPS 上,他的团队介绍了一项堆叠式胶囊自动编码器(stacked capsule autoencoders)相关的研究成果。更早之前 2 月的 AAAI 会议上,他谈到,胶囊网络是无监督学习的关键。4 月,Hinton 又重新提出了将反向传播作为人类大脑中的一种学习功能,并介绍了近似反向传播的算法 ——用活动差异表示神经梯度(neural gradient representation by activity differences,简称 NGRAD)。 近日,在播客节目 Eye on AI 中,受到播客主理人、纽约时报资深记者 Craig Smith 的邀请

How to install PyTorch with pipenv and save it to Pipfile and Pipfile.lock?

可紊 提交于 2021-01-29 18:22:00
问题 I’m currently using Pipenv to maintain the Python packages used in a specific project. Most of the downloads I’ve tried so far have worked as intended; that is, I enter pipenv install [package] and it installs the package into the virtual environment, then records the package information into both the Pipfile and Pipfile.lock. However, I’m running into some problems installing PyTorch. I’ve tried running pipenv install torch , but every time the locking step fails. Instead, I’ve tried forcing

coremltools: how to properly use NeuralNetworkMultiArrayShapeRange?

浪尽此生 提交于 2021-01-29 16:28:12
问题 I have a PyTorch network and I want to deploy it to iOS devices. In short, I fail to add flexibility to the input tensor shape in CoreML. The network is a convnet that takes an RGB image (stored as a tensor) as an input and returns an RGB image of the same size. Using PyTorch, I can input images of any size I want, for instance a tensor of size (1, 3, 300, 300) for a 300x300 image. To convert the PyTorch model to a CoreML model, I first convert it to an ONNX model using torch.onnx.export .

从BERT、XLNet到MPNet,细看NLP预训练模型发展变迁史

隐身守侯 提交于 2021-01-29 15:49:26
20世纪以来,自然语言处理(NLP)领域的发展涌现了许多创新和突破。NLP中许多之前机器不可能完成的任务,如阅读理解、人机对话、自动写新闻稿等,正逐渐成为现实,甚至超越了人类的表现。 如果总结过去20年里,无数先辈辛劳付出带来的璀璨成果,以下3个代表性工作列入NLP名人堂,应该实至名归: 1)2003年Bengio提出神经网络语言模型NNLM, 从此统一了NLP的特征形式——Embedding; 2)2013年Mikolov提出词向量Word2vec ,延续NNLM又引入了大规模预训练(Pretrain)的思路; 3)2017年Vaswani提出Transformer模型, 实现用一个模型处理多种NLP任务。 基于Transformer架构,2018年底开始出现一大批预训练语言模型,刷新众多NLP任务,形成新的里程碑事件。本文将跨越2018-2020,着眼于3个预训练代表性模型BERT、XLNet和MPNet,从以下4个章节介绍NLP预训练语言模型的发展变迁史: 1.BERT 原理及 MLM 简述 2.XLNet 原理及 PLM 简述 3.MPNet 原理及创新点简述 4.NLP预训练模型趋势跟踪 附录:快速上手BERT的4大工具包 1.BERT 原理及 MLM 简述 自谷歌2018年底开源BERT,NLP界的游戏规则某种程度上被“颠覆”了;一时间,这个芝麻街的可爱小黄人形象

How can i add a Bi-LSTM layer on top of bert model?

大憨熊 提交于 2021-01-29 15:22:30
问题 I'm using pytorch and I'm using the base pretrained bert to classify sentences for hate speech. I want to implement a Bi-LSTM layer that takes as an input all outputs of the latest transformer encoder from the bert model as a new model (class that implements nn.Module ), and i got confused with the nn.LSTM parameters. I tokenized the data using bert = BertForSequenceClassification.from_pretrained("bert-base-uncased", num_labels=int(data['class'].nunique()),output_attentions=False,output

CUDA out of memory

心不动则不痛 提交于 2021-01-29 12:58:23
问题 I am getting error when trying to run BERT model for NER task. "CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 3.82 GiB total capacity; 2.58 GiB already allocated; 25.38 MiB free; 6.33 MiB cached)I have also tried reducing batch size to 1c enter code here epochs = 10 max_grad_norm = 1.0 for _ in trange(epochs, desc="Epoch"): # TRAIN loop model.train() tr_loss = 0 nb_tr_examples, nb_tr_steps = 0, 0 for step, batch in enumerate(train_dataloader): # add batch to gpu batch = tuple(t.to

how to solve dimension mismatch error for CNN on images in pyTorch?

本小妞迷上赌 提交于 2021-01-29 12:06:30
问题 I have input data (colored images) in the shape of (100, 64, 64, 3) and tried to train a CNN with 2 conv/pooling layers on it for binary classification. I keep encountering size mismatch error. Also attempted reshape the images into (-1, 3, 64, 64) size class SimpleCNN(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim, kernel_size): super(SimpleCNN, self).__init__() self.conv1 = nn.Conv2d(3, 10, kernel_size, padding=0) self.conv2 = nn.Conv2d(10, 20, kernel_size, padding=0) self