0

I am using a very simple MLP with just 1 hidden layer to estimate option prices.

In addition to the actual output of the neural network I would also like to know the partial derivative of the output value (of each line of the data sample) with regard to one of the 6 input parameters such that the resulting value can be interpreted as the percentage change of the output with regard to a change in the input parameter.

As I am pretty new to Keras and Neural Networks in general I was not able to come up with a solution for the problem myself.

# Create Model
model = Sequential()
model.add(Dense(6, input_dim=6)) #input layer
model.add(Dense(10, activation=relu)) #hidden layer
model.add(Dense(1, activation=linear)) #output layer

# Compile Model
model.compile(loss='mse', optimizer='adam', metrics=['mae'])

# Train model
model.fit(X_train, Y_train, epochs=50, batch_size=10 verbose=2, validation_split=0.2)

# Predict Values
Y_pred = model.predict(X_test, batch_size=10)
  • 2
    Possible duplicate of [Accessing gradient values of keras model outputs with respect to inputs](https://stackoverflow.com/questions/44444475/accessing-gradient-values-of-keras-model-outputs-with-respect-to-inputs) – Dr. Snoopy Jul 13 '17 at 10:16
  • Thanks for the reference. I have a two questions regarding the solution you provide there. First: What does the subtensor model.output[0,0] represent? and Secondly would the function call just be value = jacobian(X_Test,1.)? – Marco Mohr Jul 13 '17 at 10:33
  • 1
    You should ask questions in that question, not in this one. – Dr. Snoopy Jul 13 '17 at 10:37

0 Answers0