问题
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