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
我可以知道为什么在输出层而不是隐藏层出现此错误吗?谢谢。
你有missed a closing bracket
。
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
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句