【问题标题】:SyntaxError when passing async=True to function将 async=True 传递给函数时出现语法错误
【发布时间】:2020-03-02 08:21:18
【问题描述】:
from fastai.conv_learner import *
from fastai.dataset import *

import pandas as pd
import numpy as np
import os
from PIL import Image
from sklearn.model_selection import train_test_split

导入时出现以下错误

cuda 10.1
tensorflow = 2.0.0
Traceback (most recent call last):

   File
 "/home/jake/venv/lib/python3.7/site-packages/IPython/core/interactiveshell.py",
 line 3326, in run_code
     exec(code_obj, self.user_global_ns, self.user_ns)

   File "<ipython-input-6-7dcee084b5a9>", line 1, in <module>
     from fastai.conv_learner import *

   File
 "/home/jake/venv/lib/python3.7/site-packages/fastai/conv_learner.py",
 line 1, in <module>
     from .core import *

   File "/home/jake/venv/lib/python3.7/site-packages/fastai/core.py",
 line 19
     def V_(x):  return to_gpu(x, async=True) if isinstance(x, Variable) else Variable(to_gpu(x, async=True))
                                      ^ SyntaxError: invalid syntax

【问题讨论】:

  • 您正在使用的库似乎正在尝试使用 async 作为参数名称。这是一个错误,因为async 是一个关键字。该库可能是为早期版本的 Python 编写的。也许您可以获得这些库的更新版本。

标签: python deep-learning fast-ai


【解决方案1】:

您使用的似乎是过期版本的fastai。在当前版本的 Python 中,async 是一个关键字,因此尝试将 async 用作变量或函数参数是语法错误。您使用的版本必须是为更旧版本的 Python 编写的。

我刚刚看了fastai,目前的版本没有这个问题。因此,您需要更新到与您正在使用的 Python 版本兼容的更新版本的库。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-13
    • 2014-12-10
    • 2014-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-09
    • 1970-01-01
    相关资源
    最近更新 更多