代码如下 

embeddings=torch.zeros((len(cdr3s),nfeat,cdr3max),dtype=torch.float32,device=device)

出现报错 

TypeError: zeros(): argument 'size' must be tuple of ints, but found element of type list at pos 2

修改方法

查看数据类型 

        print(type(len(cdr3s)))
        print(type(nfeat))
        print(type(cdr3max))

得到:
<class 'int'>
<class 'list'>
<class 'numpy.int64'>

在上述代码中应该输入的是数组,将<class 'list'>修改为数组,根据代码上下文应该是nfeat长度

修改为 

embeddings=torch.zeros((len(cdr3s),len(nfeat),cdr3max),dtype=torch.float32,device=device)

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐