How to perform feed forward propagation in CNN using Keras?

做~自己de王妃 提交于 2020-01-23 04:24:32

问题


I want to perform feed forward propagation on CNN using Keras. I am trying to train CNN using my own optimizer, which I can't fit in the optimiser file of Keras. My optimiser in gradient free. I don't want any inbuilt to be used.


回答1:


I found answer to this question. We just have to make model non trainable.

import numpy as np
import keras

x = keras.layers.Input(shape=(3,))
y = keras.layers.Dense(5)(x)

model = keras.models.Model(x, y)
model.trainable = False
model.compile(optimizer='rmsprop', loss='mse')

x = np.random.random((10, 3))
y = np.random.random((10, 5))
model.fit(x, y, epochs=10)


来源:https://stackoverflow.com/questions/47233306/how-to-perform-feed-forward-propagation-in-cnn-using-keras

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!