TypeError: конструктор torch.FloatTensor получил недопустимую комбинацию аргументов - got (str, int) --- при импорте fastai.text - PullRequest
0 голосов
/ 23 сентября 2018

Я пытаюсь импортировать fastai.text в python3.5 в Linux с помощью (из импорта fastai.text *).Вот ошибка, которую я получаю.

    ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-77-55ea5f35b797> in <module>()
----> 1 from fastai.text import *

/usr/local/lib/python3.5/dist-packages/fastai/text.py in <module>()
----> 1 from .core import *
      2 from .learner import *
      3 from .lm_rnn import *
      4 from torch.utils.data.sampler import Sampler
      5 import spacy

/usr/local/lib/python3.5/dist-packages/fastai/core.py in <module>()
      1 from .imports import *
----> 2 from .torch_imports import *
      3 
      4 def sum_geom(a,r,n): return a*n if r==1 else math.ceil(a*(1-r**n)/(1-r))
      5 

/usr/local/lib/python3.5/dist-packages/fastai/torch_imports.py in <module>()
     62 
     63 @_fastai_model('Inception 4', 'Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning',
---> 64                'https://arxiv.org/pdf/1602.07261.pdf')
     65 def inceptionresnet_2(pre): return load_pre(pre, InceptionResnetV2, 'inceptionresnetv2-520b38e4')
     66 

/usr/local/lib/python3.5/dist-packages/fastai/torch_imports.py in add_docs_wrapper(f)
     53         Args:
     54            pre (bool): If True, returns a model pre-trained on ImageNet
---> 55         """)
     56         return f
     57     return add_docs_wrapper

/usr/local/lib/python3.5/dist-packages/fastai/torch_imports.py in inceptionresnet_2(pre)
     63 @_fastai_model('Inception 4', 'Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning',
     64                'https://arxiv.org/pdf/1602.07261.pdf')
---> 65 def inceptionresnet_2(pre): return load_pre(pre, InceptionResnetV2, 'inceptionresnetv2-520b38e4')
     66 
     67 @_fastai_model('ResNeXt 50', 'Aggregated Residual Transformations for Deep Neural Networks',

/usr/local/lib/python3.5/dist-packages/fastai/torch_imports.py in load_pre(pre, f, fn)
     43     m = f()
     44     path = os.path.dirname(__file__)
---> 45     if pre: load_model(m, f('{path}/weights/{fn}.pth'))
     46     return m
     47 

/usr/local/lib/python3.5/dist-packages/fastai/models/inceptionresnetv2.py in __init__(self, num_classes)
    278         self.conv2d_7b = BasicConv2d(2080, 1536, kernel_size=1, stride=1)
    279         self.avgpool_1a = nn.AvgPool2d(8, count_include_pad=False)
--> 280         self.last_linear = nn.Linear(int(1536), num_classes)
    281 
    282     def features(self, input):

/usr/local/lib/python3.5/dist-packages/torch/nn/modules/linear.py in __init__(self, in_features, out_features, bias)
     39         self.in_features = int(in_features)
     40         self.out_features = int(out_feature)
---> 41         self.weight = Parameter(torch.FloatTensor(int(out_features),int(in_features)))
     42         if bias:
     43             self.bias = Parameter(torch.FloatTensor(int(out_features)))

TypeError: torch.FloatTensor constructor received an invalid combination of arguments - got (str, int), but expected one of:
 * no arguments
 * (int ...)
      didn't match because some of the arguments have invalid types: (str, int)
 * (torch.FloatTensor viewed_tensor)
 * (torch.Size size)
 * (torch.FloatStorage data)
 * (Sequence data)

Я попытался преобразовать аргумент в int, но получил ту же ошибку.Я попытался преобразовать каждый аргумент из строки 39 до 43 в int, но все еще та же ошибка.

...