我正在尝试安装 FastAi 库并将其与 Google Colab 一起使用。我是
使用:
!pip3 install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision
import torch
!pip install Pillow==4.1.1
!pip install image
%matplotlib inline
导入/安装所有东西,但是当我运行时
from fastai.imports import *
最后一行给出了一个错误,内容如下:
ImportError:无法导入名称“as_tensor”
有谁知道我做错了什么/为什么在安装的第一件东西时它不导入 fastai 库?
我收到的完整错误如下:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-10-9f9378ae0f2a> in <module>()
----> 1 from fastai.imports import *
/usr/local/lib/python3.6/dist-packages/fastai/__init__.py in <module>()
----> 1 from .basic_train import *
2 from .callback import *
3 from .callbacks import *
4 from .core import *
5 from .data import *
/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in <module>()
1 "Provides basic training and validation with `Learner`"
----> 2 from .torch_core import *
3 from .data import *
4 from .callback import *
5
/usr/local/lib/python3.6/dist-packages/fastai/torch_core.py in <module>()
1 "Utility functions to help deal with tensors"
----> 2 from .imports.torch import *
3 from .core import *
4
5 AffineMatrix = Tensor
/usr/local/lib/python3.6/dist-packages/fastai/imports/__init__.py in
<module>()
1 from .core import *
----> 2 from .torch import *
/usr/local/lib/python3.6/dist-packages/fastai/imports/torch.py in <module>()
1 import torch, torch.nn.functional as F
2 from torch import ByteTensor, DoubleTensor, FloatTensor, HalfTensor,
LongTensor, ShortTensor, Tensor
----> 3 from torch import nn, optim, as_tensor, tensor
4 from torch.utils.data import BatchSampler, DataLoader, Dataset, Sampler,
TensorDataset
ImportError: cannot import name 'as_tensor'