【问题标题】:VIsual Studio Code does not highlight error in Keras codeVIsual Studio 代码不会突出显示 Keras 代码中的错误
【发布时间】:2019-12-04 00:56:33
【问题描述】:

更新:

settings.json

{
    "python.pythonPath": "/home/winston/anaconda3/envs/gpu/bin/python"
}

我有代码使用 Keras 训练模型,然后保存训练好的模型。

model.save('incepv3_transfer.h5', overwrite=True, include_optimizer=True, save_format='h5')

save_format 参数不应存在,因为 save() 方法没有该参数

但是 VSC 没有提供错误信息。

有谁知道如何解决这个问题?

【问题讨论】:

  • 你设置了哪些 linter 来检测这类事情?
  • 嗨 @BrettCannon 我是 Python 新手,在哪里可以看到 linter?
  • 请分享您在 VS Code 中的所有 "python" 设置(最简单的方法可能是从您的 settings.json 文件中复制它们)。
  • 嗨 @BrettCannon 更新了,请看一下

标签: python tensorflow keras visual-studio-code tf.keras


【解决方案1】:

检测错误(例如使用不正确的参数调用)由 linter 处理。您需要安装一个并在 VS Code 中打开它们,例如 flake8、Pylint、mypy 等。如果您正确地完成了这些操作,您最终会得到一些 "python.linting.<linter>Enabled": true 形式的设置。

请参阅documentation on linting,详细了解支持哪些 linter 以及使用哪些设置。

【讨论】:

  • 谢谢@Brett,我这里用的函数是Keras函数,Pylint怎么知道Keras中的参数??
  • @Franva Pylint 将尝试分析代码以找出答案,否则它可能会尝试使用提供的类型存根。
猜你喜欢
  • 2019-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多