Python 类型错误-Torch.Device RepeatedScalarContainer

Python 类型错误-Torch.Device RepeatedScalarContainer,python,pytorch,ml-agent,Python,Pytorch,Ml Agent,我不断收到错误TypeError:new()收到无效的参数组合-get(google.protobuf.pyext.\u message.RepeatedScalarContainer,int) 我已经打印了设备的类型,发现它属于torch.device类,并在一个单独的程序中测试了所有相关命令。相关代码在下面,错误在下面。我和Unity的ML代理一起使用。有什么问题吗 device = torch.device("cuda:0" if torch.cuda.is_available() els

我不断收到错误
TypeError:new()收到无效的参数组合-get(google.protobuf.pyext.\u message.RepeatedScalarContainer,int)

我已经打印了
设备的类型
,发现它属于
torch.device类
,并在一个单独的程序中测试了所有相关命令。相关代码在下面,错误在下面。我和Unity的ML代理一起使用。有什么问题吗

device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
print(type(device))

class Agent():
    """Interacts with and learns from the environment."""

    def __init__(self, state_size, action_size, random_seed):
        """Initialize an Agent object.

        Params
        ======
            state_size (int): dimension of each state
            action_size (int): dimension of each action
            random_seed (int): random seed
        """
        self.state_size = state_size
        self.action_size = action_size
        self.seed = random.seed(random_seed)

        # Actor Network (w/ Target Network)
        self.actor_local = Actor(state_size, action_size, random_seed).to(device)
        self.actor_target = Actor(state_size, action_size, random_seed).to(device)
        self.actor_optimizer = optim.Adam(self.actor_local.parameters(), lr=LR_ACTOR)
回溯(最近一次呼叫最后一次):
文件“train.py”,第87行,在
代理\u 1=代理(状态\u大小=48,操作\u大小=操作\u大小,随机\u种子=0)
文件“C:\Users\Tester\ml-agents\ml-agents\mlagents\trainers\ddpg\ddpg\u-agent.py”,第39行,在\u\u init中__
self.actor\u local=actor(状态大小、动作大小、随机种子)。到(设备)
文件“C:\Users\Tester\ml agents\ml agents\mlagents\trainers\ddpg\model.py”,第29行,在\uuu init中__
self.fc3=nn.线性(fc2单位,动作大小)
文件“C:\Users\Tester\AppData\Local\conda\conda\envs\ml agents\lib\site packages\torch\nn\modules\linear.py”,第51行,在__
自重=参数(火炬张量(out_特征、in_特征))
TypeError:new()接收到无效的参数组合-get(google.protobuf.pyext.\u message.RepeatedScalarContainer,int),但应为以下参数之一:
*(火炬装置)
*(火炬.储存)
*(张量其他)
*(整数大小的元组,torch.device)
不匹配,因为某些参数的类型无效:(e[31;1mgoogle.protobuf.pyext.\u message.RepeatedScalarContainere[0m,e[31;1minte[0m)
*(对象数据,torch.device)
不匹配,因为某些参数的类型无效:(e[31;1mgoogle.protobuf.pyext.\u message.RepeatedScalarContainere[0m,e[31;1minte[0m)

根据错误消息,当tensor对象需要int时,在某个地方向其输入
google.protobuf.pyext.\u message.RepeatedScalarContainer
Traceback (most recent call last):
  File "train.py", line 87, in <module>
    agent_1 = Agent(state_size=48, action_size=action_size, random_seed=0)
  File "C:\Users\Tester\ml-agents\ml-agents\mlagents\trainers\ddpg\ddpg_agent.py", line 39, in __init__
    self.actor_local = Actor(state_size, action_size, random_seed).to(device)
  File "C:\Users\Tester\ml-agents\ml-agents\mlagents\trainers\ddpg\model.py", line 29, in __init__
    self.fc3 = nn.Linear(fc2_units, action_size)
  File "C:\Users\Tester\AppData\Local\conda\conda\envs\ml-agents\lib\site-packages\torch\nn\modules\linear.py", line 51, in __init__
    self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: new() received an invalid combination of arguments - got (google.protobuf.pyext._message.RepeatedScalarContainer, int), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
      didn't match because some of the arguments have invalid types: (e[31;1mgoogle.protobuf.pyext._message.RepeatedScalarContainere[0m, e[31;1minte[0m)
 * (object data, torch.device device)
      didn't match because some of the arguments have invalid types: (e[31;1mgoogle.protobuf.pyext._message.RepeatedScalarContainere[0m, e[31;1minte[0m)