Fastaiimports



While executing the command from fastai.imports import * in colab, I am getting the error cannot import name as_tensor(image is attached)

Can anyone help me to resolve this?

I’m not 100% how colab works but that may be because it isn’t the most updated version of Torch. Is there a way to specify you want to use the nightly build of Torch? Unless you are trying to use the older version of fastai in which case, check this out and see if it helps you: ImportError: cannot import name ‘as_tensor’?

I had this same problem: 'cannot import name ‘as_tensor’. Here is my reasoning that led to the fix:

  • as_tensor is missing from torch (pytorch)
  • maybe I don’t have the latest v1 of pytorch even though I followed the install instructions for the 2019 course. This is likely because I used the same machine to do the 2018 course, before pytorch v1 existed.
  • from within my new conda environment, I run: $ conda list pytorch
    and get response “pytorch 0.3.1”
  • $ conda install -c pytorch pytorch=1.0
    This solved the problem
1 Like

I had the exact same issue, I took the 2018 course. Running conda install -c pytorch pytorch=1.0 solved the problem.

1 Like

Programming is a crucial prerequisite for anyone wanting to learn machine learning upsers portal. Sure quite a few autoML tools are out there, but most are still at a very nascent stage and well beyond an individual’s budget. The sweet spot for a data scientist lies in combining programming with machine learning algorithms.