首页 > 其他分享 >torch.arange()

torch.arange()

时间:2022-12-31 22:34:08浏览次数:54  
标签:end text torch arange start step

TORCH.ARANGE

torch.arange(start=0endstep=1*out=Nonedtype=Nonelayout=torch.strideddevice=Nonerequires_grad=False)→ Tensor

Returns a 1-D tensor of size \left\lceil \frac{\text{end} - \text{start}}{\text{step}} \right\rceil⌈stepend−start​⌉ with values from the interval [start, end) taken with common difference step beginning from start.

Note that non-integer step is subject to floating point rounding errors when comparing against end; to avoid inconsistency, we advise adding a small epsilon to end in such cases.

\text{out}_{{i+1}} = \text{out}_{i} + \text{step}outi+1​=outi​+step
Parameters:
  • start (Number) – the starting value for the set of points. Default: 0.

  • end (Number) – the ending value for the set of points

  • step (Number) – the gap between each pair of adjacent points. Default: 1.

>>> torch.arange(5)
tensor([ 0,  1,  2,  3,  4])
>>> torch.arange(1, 4)
tensor([ 1,  2,  3])
>>> torch.arange(1, 2.5, 0.5)
tensor([ 1.0000,  1.5000,  2.0000])

 

标签:end,text,torch,arange,start,step
From: https://www.cnblogs.com/yuxiyuxi/p/17017477.html

相关文章

  • pytorch的FashionMNIST
    目录pytorch的FashionMNIST项目从加载数据到训练模型评估到模型保存模型加载及预测importtorchfromtorchimportnnfromtorch.utils.dataimportDataLoaderfromtorchvi......
  • Pytorch优化过程展示:tensorboard
      训练模型过程中,经常需要追踪一些性能指标的变化情况,以便了解模型的实时动态,例如:回归任务中的MSE、分类任务中的Accuracy、生成对抗网络中的图片、网络模......
  • PyTorch学习笔记 7.TextCNN文本分类
    PyTorch学习笔记7.TextCNN文本分类​​一、模型结构​​​​二、文本分词与编码​​​​1.分词与编码器​​​​2.数据加载器​​​​二、模型定义​​​​1.卷积层​​......
  • pytorch模型onnx部署(python版本,c++版本)
    转载:实践演练BERTPytorch模型转ONNX模型及预测-知乎(zhihu.com)使用bRPC和ONNXRuntime把BERT模型服务化-知乎(zhihu.com)1.安装anaconda一般有图形界面的个人电......
  • ubuntu pytorch install
    nvidia驱动安装https://www.cnblogs.com/lif323/p/17014199.htmlconda安装下载.sh到该网站下载需要的.sh文件wgethttps://repo.anaconda.com/archive/Anaconda3-20......
  • torch.nn.MaxPool2d()
    torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)\(2D\)最大池化。参数:kernel_size:最大池化......
  • pytorch:二分类时的loss选择
    PyTorch二分类时BCELoss,CrossEntropyLoss,Sigmoid等的选择和使用这里就总结一下使用PyTorch做二分类时的几种情况:总体上来讲,有三种实现形式:最后分类层降至一维,使用sigmo......
  • torch.cat() 与 torch.stack() 的区别
    目录1.torch.cat()2.torch.stack()1.torch.cat()torch.cat(tensors, dim=0)在给定维度中拼接张量序列。参数:tensors:张量序列。dim:拼接张量序列的维度。impo......
  • PyTorch模型保存与加载
    保存与加载整个模型保存整个模型,包括网络结构和权重参数,保存后的文件用torch.load()加载后的类型是定义的网络结构类,如classCNN:torch.save(model,"model.pkl")加载整......
  • PyTorch的Dataset 和TorchData API的比较
    深度神经网络需要很长时间来训练。训练速度受模型的复杂性、批大小、GPU、训练数据集的大小等因素的影响。在PyTorch中,torch.utils.data.Dataset和torch.utils.data.DataL......