简体   繁体   English

类型错误:tensor() 得到了一个意外的关键字参数“名称”

[英]TypeError: tensor() got an unexpected keyword argument 'names'

so I started reading deep learning with pytorch, and got to the point of setting names to the dimensions inside the tensor, to make it more friendly, but as soon as I use the names argument, I get the error:所以我开始使用 pytorch 阅读深度学习,并开始将名称设置为张量内部的维度,以使其更加友好,但是一旦我使用 names 参数,我就会收到错误:

TypeError: tensor() got an unexpected keyword argument 'names'

can anyone help me out?谁能帮我吗?

The code is simple:代码很简单:

import torch

weights_named = torch.tensor([0.2126, 0.7152, 0.0722], names=['channels'])
weights_named

Just want to run this, to see how to set names to the dimensions.只想运行这个,看看如何为维度设置名称。 Thanks in advance.提前致谢。

This is due to your PyTorch Version.这是由于您的 PyTorch 版本。 Upgrade your Pytorch version and should work.升级你的 Pytorch 版本,应该可以工作。 In my case,就我而言,

import torch
torch.__version__ #1.7
weights_named = torch.tensor([0.2126, 0.7152, 0.0722], names=['channels'])
# __main__:1: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change.

Named tensors and functions supporting it on latest 1.9 release, but on 1.7 (my version) is still experimental.在最新的 1.9 版本中支持它的命名张量和函数,但在 1.7(我的版本)上仍然是实验性的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError: __init__() 得到了一个意外的关键字参数 'tensor_type' - TypeError: __init__() got an unexpected keyword argument 'tensor_type' TypeError:得到一个意外的关键字参数 - TypeError: got an unexpected keyword argument 运行张量流模型`TypeError:__init __()时出错,得到了意外的关键字参数'file'。 - Error running tensor flow model `TypeError: __init__() got an unexpected keyword argument 'file'` TypeError:得到了意外的关键字参数“ name” - TypeError: got an unexpected keyword argument “name” 类型错误:binarySearch() 得到了一个意外的关键字参数“key” - TypeError: binarySearch() got an unexpected keyword argument 'key' TypeError:histogram()得到了意外的关键字参数“ new” - TypeError: histogram() got an unexpected keyword argument 'new' TypeError:urlopen()获得了意外的关键字参数'headers' - TypeError: urlopen() got an unexpected keyword argument 'headers' TypeError:得到了一个意外的关键字参数“图像” - TypeError: got an unexpected keyword argument 'image' TypeError: concatenate() 得到了一个意外的关键字参数“dtype” - TypeError: concatenate() got an unexpected keyword argument 'dtype' TypeError: mannwhitneyu() 得到了一个意外的关键字参数“方法” - TypeError: mannwhitneyu() got an unexpected keyword argument 'method'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM