pytorch gather_【Pytorch】Pytorch-1.1.0 版本新特性

v2-3fcad7f7b3b167f7b10f84c2012bc9d2_1440w.jpg?source=172ae18b
2019年05月01日,Pytorch 1.1.0 版本正式发布啦~https://github.com/pytorch/pytorch/releases/tag/v1.1.0

主要的几个功能:
1. TensorBoard (currently experimental)
2. JIT 的升级
· [JIT] Attributes in ScriptModules
· [JIT] Dictionary and List Support in TorchScript
· [JIT] User-defined classes in TorchScript (experimental)
3. DistributedDataParallel new functionality and tutorials

TensorBoard (currently experimental)

  • PyTorch now supports TensorBoard logging with a simplefrom torch.utils.tensorboard import SummaryWritercommand.
  • Histograms, embeddings, scalars, images, text, graphs, and more can be visualized across training runs.
  • TensorBoard support is currently experimental. You can browse the docs here.

JIT

  • Attributes in ScriptModules
  1. Attributes can be assigned on a ScriptModule by wrapping them with torch.jit.Attribute and specifying the type.
  2. They will be serialized along with any paramters/buffers when you call torch.jit.save() , so they are a great way to store arbitrary state in your model.
  3. See the docs for more info.
  4. Example:
class Foo(torch.jit.ScriptModule):def __init__(self, a_dict):super(Foo, self).__init__(False)self.words = torch.jit.Attribute([], List[str])self.some_dict = torch.jit.Attribute(a_dict, Dict[str, int])@torch.jit.script_methoddef forward(self, input: str) -> int:self.words.append(input)return self.some_dict[input]
  • Dictionary and List Support in TorchScript
  1. TorchScript now has robust support for list and dictionary types. They behave much like Python lists and dictionaries, supporting most built-in methods, as well as simple comprehensions and for…in constructs.
  • User-defined classes in TorchScript (experimental)
  1. For more complex stateful operations, TorchScript now supports annotating a class with @torch.jit.script. Classes used this way can be JIT-compiled and loaded in C++ like other TorchScript modules.
  2. See the docs for more info.
  3. Example:
@torch.jit.script
class Pair:def __init__(self, first, second)self.first = firstself.second = seconddef sum(self):return self.first + self.second

DistributedDataParallel new functionality and tutorials

  • nn.parallel.DistributedDataParallel: can now wrap multi-GPU modules, which enables use cases such as model parallel (tutorial) on one server and data parallel (tutorial) across servers. (19271).

Breaking Changes

  • Tensor.set_: the device of a Tensor can no longer be changed via Tensor.set_. This would most commonly happen when setting up a Tensor with the default CUDA device and later swapping in a Storage on a different CUDA device. Instead, set up the Tensor on the correct device from the beginning. (18832).
  • Pay attention to the order change of lr_scheduler.step(). (7889).
  • torch.unique: changed the default value of sorted to True. (15379).
  • [JIT] Rename isTensor api -> isCompleteTensor. #18437
  • [JIT] Remove GraphExecutor's python bindings. #19141
  • [C++]: many methods on Type no longer exist; use the functional or Tensor method equivalent. (17991).
  • [C++]: the Backend constructor of TensorOptions no longer exists. (18137).
  • [C++, Distributed]: Remove c10d ProcessGroup::getGroupRank has been removed. (19147).

【New Features】
这次的版本更新添加了很多可调用的方法。

Operators

  • torch.tril_indices, torch.triu_indices: added operator with same behavior as NumPy. (14904, 15203).
  • torch.combinations, torch.cartesian_prod: added new itertools-like operators. (9393).
  • torch.repeat_interleave: new operator similar to numpy.repeat. (18395).
  • torch.from_file: new operator similar to Storage.from_file, but returning a tensor. (18688).
  • torch.unique_consecutive: new operator with semantics similar to std::unique in C++. (19060).
  • torch.tril, torch.triu, torch.trtrs: now support batching. (15257, 18025).
  • torch.gather: add support for sparse_grad option. (17182).
  • torch.std, torch.max_values, torch.min_values, torch.logsumexp can now operate over multiple dimensions at once. (14535, 15892, 16475).
  • torch.cdist: added operator equivalent to scipy.spatial.distance.cdist. (16168, 17173).
  • torch.__config__.show(): reports detailed version of all libraries. (18579).

NN

  • nn.MultiheadedAttention: new module implementing MultiheadedAttention from Attention Is All You Need. (18334).
  • nn.functional.interpolate: added support for bicubic. (9849).
  • nn.SyncBatchNorm: support synchronous Batch Normalization. (14267).
  • nn.Conv: added support for Circular Padding via mode='circular'. (17240).
  • nn.EmbeddingBag: now supports trainable per_sample_weights. (18799).
  • nn.EmbeddingBag: add support for from_pretrained method, as in nn.Embedding. (15273).
  • RNNs: automatically handle unsorted variable-length sequences via enforce_sorted. (15225).
  • nn.Identity: new module for easier model surgery. (19249).

Tensors / dtypes

  • torch.bool: added support for torch.bool dtype and Tensors with that dtype (1-byte storage). NumPy conversion is supported, but operations are currently limited. (16810).

Optim

  • optim.lr_scheduler.CyclicLR: Support for Cyclical Learning Rate and Momentum. (18001).
  • optim.lr_scheduler.CosineAnnealingWarmRestarts: new scheduler: Stochastic Gradient Descent with Warm Restarts). (17226).
  • Support multiple simultaneous LR schedulers. (14010)

Distributions

  • torch.distributions: now support multiple inheritance. (16772).

Samplers

  • quasirandom.SobolEngine: new sampler. (10505).

DistributedDataParallel

  • nn.parallel.DistributedDataParallel: now supports modules with unused parameters (e.g. control flow, like adaptive softmax, etc). (18251, 18953).

TorchScript and Tracer

  • Allow early returns from if-statements. (#154463)
  • Add an @ignore annotation, which statically tells the TorchScript compiler to ignore the Python function. (#16055)
  • Simple for...in loops on lists. (#16726)
  • Ellipses (...) in Tensor indexing. (#17763)
  • None in Tensor indexing. (#18615)
  • Support for basic list comprehensions. (#17267)
  • Add implicit unwrapping of optionals on if foo is not None. (#15587)
  • Tensors, ints, and floats will once again be implicitly cast to bool if used in a conditional. (#18755).
  • Implement to(), cpu(), and cuda() on ScriptModules. (#15340 , #15904)
  • Add support for various methods on lists: (clear(), pop(), reverse(), copy() , extend(),index(), count(), insert(), remove() ).
  • Add support for sort() on lists of specialized type (Tensors, int, float, bool). (#19572)
  • Add support for various methods on strings: (index(), slice(), len())
  • Support Tensor.to() in TorchScript. ( #15976 )
  • Support for Torch.tensor() in TorchScript. (#14913, #19445)
  • Support for torch.manual_seed() in TorchScript. (#19510)
  • Support for nn.LSTM in TorchScript. (#15744)
  • Support for nn.init in TorchScript. (#19640)
  • Add hash() builtin. (#18258)
  • Add min() and max() builtins for numerical types. (#15680)
  • Add isinstance() builtin, which performs a static type check. (#15076)
  • Add train() / eval() / is_training() to C++ ScriptModule API. (#16044)
  • Allow List arguments to Python functions called from TorchScript. (#15721)
  • Allow using std::vector and std::unordered_map as arguments to custom operators. (#17587)
  • Tracer: now allows passing static dicts and lists as trace inputs. (#18092, #19580)
  • Allow generic containers as ScriptModule inputs. (#16482)
  • Allow nn.Sequential in ModuleList. (#16882)

Experimental Features

  • [Quantization] (API unstable): added limited support for quantized datatypes via torch.qint8 dtype, torch.quantize_linear conversion function. (18230).
  • [MKLDNN tensor] (API unstable): Added limited (opaque) support for MKLDNN tensors via Tensor.to_mkldnn(); operators are currently limited to ResNext101 operators. (17748).

另外,日志里还有关于【Improvements】【Bug Fixes】【Deprecations】【Performance】【Documentation】【ONNX】的说明。

下边是已经修复了的比较严重的一些Bug。

  • torch.prod: correct erroneous calculation on large tensors. (15653).
  • torch.mean (and other reductions): fix incorrect calculation on CUDA on large inputs. (16023).
  • nn.Conv: correctly handle non-contiguous inputs on MKLDNN convolution codepath. (16300).
  • Tensor.eq_: Fix erroneous calculation. (15475).
  • torch.mean: Fix fp16 output calculation. (14878).
  • nn.PoissonNLLLoss: Properly handle reduction=None. (17358).
  • [JIT] Fix bug where custom ops could get optimized out if their outputs weren't used. (#18711).
  • [JIT] Fix bug where the model serializer would accidentally reorder statements. (#17557).

下边是挑出的几个比较显著的【Performance】。

  • nn.BatchNorm CPU inference speed increased up to ~19x.(19152).
  • nn.AdaptiveAvgPool: speed up common-case of size=1 output by ~30x. (17011).
  • nn.EmbeddingBag CPU performance increased by ~4x. (19329).
  • Tensor.copy_: sped up larger tensor copy ~2-3x, small regression in small tensor copy. (18618).
  • torch.nonzero: is now ~2x faster than numpy on CPU. (15190)
  • Improve caching allocator for Pascal and newer GPUs; 10-20% better memory utilization on Mask-RCNN. (17120).
  • reduction functions: Speed up some large Tensor cases by 50-80%. (17428).
  • [JIT] Graph fuser: better fusion for backwards graphs in the presence of broadcasting. (#14957)
  • [JIT] Graph fuser: batch_norm fusion for inference. (#15146)
  • [JIT] Graph fuser: layer_norm fusion for inference. (#18266)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/428251.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MySQL-5.7.21非图形化下载、安装、连接问题记录

1、安装包下载链接:https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-winx64.zip 官网:https://www.mysql.com/downloads/ -> Community ->MySQl Community Sever ->选择与电脑对应的版本DownLoad 2、解压安装包到自定义的文件夹…

c++定义一个动态全局变量_静态链接与动态链接的宏观概述及微观详解

静态链接与动态链接的宏观概述及微观详解第一部分 宏观概述 1. 静态链接静态链接就是在程序运行前,链接器通过对象文件中包含的重定位表,完成所有重定位操作,并最终形成一个在运行时不需要再次进行依赖库的加载和重定位操作(因为所…

pwm控制舵机转动角度程序_Mixly 第15课 舵机的使用

第15课 舵机的使用舵机的旋转不像普通电机那样只是转圈圈,它可以根据你的指令旋转到0至180度之间的任意角度然后精准的停下来。舵机的转动的角度是通过调节PWM(脉冲宽度调制)信号的占空比来实现的。舵机比较多的用于对角度有要求的场合,比如机器人、摄像…

1、初始JAVA

一、 语言的翻译分两种: 编译型语言:例如c语言、c语言 优点:速度快 缺点:不能跨平台 编译器编译——>特定平台的目标文件obj——>特定平台 解释型语言:例如PHP语言、JavaScript语言 优点&am…

base64 转文件_PHP伪协议与文件包含

PHP伪协议与文件包含PHP伪协议与文件包含php:// 协议php://inputphp://filterdata:// 协议file:// 协议zip://、bzip2://、zlib://协议zip://协议bzip2://协议zlib://协议phar://伪协议文件包含漏洞(File Inclusion)文件包含漏洞:即file inclusion,意思是…

redis 登录_Redis集群架构+Dubbo开发框架+SSO单点登录+Nginx+ZooKeeper

Redis集群架构【课程介绍】Redis是现在使用为广泛的NoSQL数据库技术,其自身不仅拥有着良好的操作性能,也被广泛的应用于各种集群架构的数据整合处理之中,而本课程将通过Redis的核心作用,以及单实例redis存在的问题为读者进行分析&…

NopCommerce用.net core重写ef

最近看了NopCommerce源码,用core学习着写了一个项目,修改的地方记录下。项目地址 NopCommerce框架出来好久了。18年的第一季度 懒加载出来后也会全部移动到.net core。那么就更好玩了。 项目内容 模仿部分分层模式引擎机制DI容器EF仓储模式Mapping部分修…

服务器u8系统数据库不存在,用友u8服务器端数据库不装

用友u8服务器端数据库不装 内容精选换一换本章节指导您使用MongoDB客户端,通过弹性云服务器内网方式连接GaussDB(for Mongo)集群实例。操作系统使用场景:弹性云服务器的操作系统以Linux为例,客户端本地使用的计算机系统以Windows为例。目标实…

ie传递给系统调用的数据区域太小_内存区域与内存溢出异常

自动内存管理机制运行时数据区:Java虚拟机定义了在程序执行期间使用的各种运行时数据区域。其中一些数据区域是在Java虚拟机启动时创建的,仅在Java虚拟机退出时销毁。其他数据区域是每个线程所占的空间。线程数据区域是随着线程销毁和创建的。PC 寄存器(…

0010服务器无对应信息,服务器版本对应的内存

服务器版本对应的内存 内容精选换一换硬件要求如表1所示。操作系统要求如表2所示。上表中所需Ubuntu下载地址:服务器1:Ubuntu 18.04.1镜像包、Ubuntu 16.04.4 镜像包。服务器2:Ubuntu 16.04.3 镜像包。在安装操作系统过程中“选择软件列表”时…

idea中连接mysql插入成功数据 在navicat中刷新表格没有数据_MySQL入门简记

1、MySQL和Navicat的安装下载地址:MySQL官方网站 https://dev.mysql.com/downloads双击下载的mysql-installer-community-8.0.17.0 .msi开始安装。需要注意(Authentication Method)这一步:因为需要使用客户端navicat,在…

for循环数据量太大_中文文本分类roberta大力出奇迹之数据量大的问题

问题描述: 笔者在文本分类场景中使用了robertapooldense的三分类模型。采用预训练模型做项目的时候经常苦于数据太少,模型泛化性差,因此收集了1300W数据。在我尝试暴力出奇迹的时候,遇到了部分问题,在此记录一下。一. 数据预处理时…

future.cancel不能关闭线程_彻底弄懂线程池-newFixedThreadPool实现线程池

public class ExecutorServiceTest {public static void main(String[] args) throws IOException, InterruptedException {// 创建一个固定大小的线程池ExecutorService service Executors.newFixedThreadPool(3);for (int i 0; i < 10; i) {System.out.println("创…

Spring实战(十三)Spring事务

1、什么是事务&#xff08;Transaction&#xff09;&#xff1f; 事务是指逻辑上的一组操作&#xff0c;要么全部成功&#xff0c;要么全部失败。 事务是指将一系列数据操作捆绑成为一个整体进行统一管理。如果某一事务执行成功&#xff0c;则该事务中进行的所有数据更改均会提…

解密SVM系列(二):SVM的理论基础(转载)

解密SVM系列&#xff08;二&#xff09;&#xff1a;SVM的理论基础 原文博主讲解地太好了 收藏下 解密SVM系列&#xff08;三&#xff09;&#xff1a;SMO算法原理与实战求解 支持向量机通俗导论&#xff08;理解SVM的三层境界&#xff09; 上节我们探讨了关于拉格朗日乘子…

cout输出数组_让程序从1开始一直执行++操作,10秒钟能输出最大的数是多少

问题描述如果写一段代码&#xff0c;让程序从 1 开始一直执行 操作&#xff0c;在规定的 10s 钟内&#xff0c;你能输出的最大数是多少&#xff1f;并将它打印到屏幕上。乍一看&#xff0c;你会觉得它是一道算法题&#xff0c;再细想&#xff1a;不对&#xff01;这可能是一道…

微信公众号管理

微信公众号图文编辑 在新建图文时&#xff0c;如果有想插入的视频&#xff0c;可以采取获取视频链接再导入的方法&#xff0c;这样会更高效美观。 摘要和多个图文信息的重叠 新建图文信息&#xff0c;在设置封面旁边有图文摘要&#xff0c;图文摘要会在发送出去的界面旁边有显…

页面模板

找了半天的公众号模板&#xff0c;有点坑&#xff0c;微信公众号更新太快了&#xff0c;几个月不看都找不到使用功能了。 页面模板位置 页面模板在现在的话题专辑&#xff0c;如图: 在页面排版中可以实现我一直想要的菜单整理化功能 可以将文章整理后&#xff0c;发布在菜单…

SQL语句输出

select ,print均可以做输出 但如果想用print同时输出字符串和数字时&#xff0c;就需要遇到转换函数convert: declare allstudents int e.g.print’毕业人数为’convert(char,allstudents) 在执行时可能会遇到结果中显示了你的输出信息&#xff0c;而在消息中却没有&#xff0…

.NET面试题解析(04)-类型、方法与继承

转自:http://www.cnblogs.com/anding/p/5248973.html 常见面试题目: 1. 所有类型都继承System.Object吗&#xff1f; 2. 解释virtual、sealed、override和abstract的区别 3. 接口和类有什么异同&#xff1f; 4. 抽象类和接口有什么区别&#xff1f;使用时有什么需要注意的吗&a…