tensorflow中神经网络加层错误
我试图在tensorflow中创建一个2层神经网络模型,但得到了以下错误:tensorflow中神经网络加层错误,tensorflow,neural-network,tensorflow2.0,Tensorflow,Neural Network,Tensorflow2.0,我试图在tensorflow中创建一个2层神经网络模型,但得到了以下错误: import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras import models from tensorflow.keras import layers from tensorflow.
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
文件“”,第7行
network.add(layers.Dense(8,activation='softmax'))#这是输出层
^
SyntaxError:无效语法
我可以知道为什么我在输出层而不是隐藏层上得到这个错误吗?谢谢。您错过了一个结束括号
File "<ipython-input-6-0dde2ff676f8>", line 7
network.add(layers.Dense(8, activation = 'softmax')) # this is the output layer
^
SyntaxError: invalid syntax
第7行缺少一个)
。
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