【发布时间】:2020-09-15 23:25:10
【问题描述】:
import tensorflow as tf
from tensorflow.keras.datasets import mnist
from tensorflow.keras import models
from tensorflow.keras import layers
from tensorflow.keras.utils import to_categorical
network=models.Sequential() # this initializes a sequential model that we will call network
network.add(layers.Dense(10, activation = 'relu') # this adds a dense hidden layer
network.add(layers.Dense(8, activation = 'softmax')) # this is the output layer
我正在尝试在 tensorflow 中创建一个 2 层神经网络模型并收到此错误:
File "<ipython-input-6-0dde2ff676f8>", line 7
network.add(layers.Dense(8, activation = 'softmax')) # this is the output layer
^
SyntaxError: invalid syntax
我可以知道为什么输出层会出现此错误,而隐藏层不会出现此错误吗?谢谢。
【问题讨论】:
-
您在第 7 行缺少
)。
标签: tensorflow neural-network tensorflow2.0