【问题标题】:Why am I getting a syntax error on this code from the tensorflow website? [closed]为什么我从 tensorflow 网站收到此代码的语法错误? [关闭]
【发布时间】:2020-11-12 11:20:26
【问题描述】:

我正在使用tensorflow网站学习tensorflow,我直接从他们的网站上复制代码来测试自己。但是,由于某种原因,由于语法错误,我无法运行代码。如果我没有调整任何代码,这有什么问题?

classifier = tf.estimator.DNNClassifier(
    feature_columns=my_feature_columns,
    # Two hidden layers of 30 and 10 nodes respectively.
    hidden_units=[30, 10],
    # The model must choose between 3 classes.
    n_classes=3

classifier.train(
    input_fn=lambda: input_fn(train, train_y, training=True),
    steps=5000)

classifier.evaluate(input_fn=lambda: input_fn(test, test_y, training=False))

【问题讨论】:

  • 不要使用图片,而是复制粘贴代码

标签: python tensorflow syntax-error


【解决方案1】:

您必须在第 45 行的 n_classes=3 之后加上右括​​号。

【讨论】:

    【解决方案2】:

    您似乎忘记在第 45 行关闭括号:

        n_classes=3
    )  # <-- this one
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多