from keras.models import Sequential,Model from keras.layers import Dense,Activation,Input input = Input(shape=(784,)) x1 = Dense(64,activation='relu')(input) #第一根隐含层,以input作为参数 x2 = Dense(64,activation='relu')(x1)# 第二个隐含层,以第一个隐含层的输出作为参数 y = Dense(10,activation='softmax')(x2) #输出层 model = Model(inputs = input,outputs = y)#定义模型 model.compile(optimizer='rmsprop',loss = 'categorical_crosseentropy')#对模型进行编译。optimizer优化器,loss损失函数 metrics = ['accuracy'] model.fit(data,labels) #训练网络
Keras实现神经网络步骤
猜你喜欢
转载自blog.csdn.net/wang263334857/article/details/88423571
今日推荐
周排行