import keras
from keras.models import Sequential
from keras.layers import Dense
from keras.layers.advanced_activations import LeakyReLU, PReLU
model = Sequential()
model.add(Dense(output_dim = 20, init = 'uniform', activation = 'relu', input_dim = 1,use_bias=True))
model.add(Dense(output_dim = 20, init = 'uniform', activation = 'relu',use_bias=True))
model.add(Dense(output_dim = 20, init = 'uniform', activation = 'relu',use_bias=True))
model.add(Dense(output_dim = 1,init='uniform',activation='sigmoid'))`
现在,我希望神经网络的输出满足以下微分方程:
dy/dx+y=x
其中x介于0和1之间。 假设N代表构造的神经网络的输出,我想要以下损失函数
∑(dN/dx_i+N-x_i)^2
如何使用Keras顺序模型做到这一点?