0
$\begingroup$

I have an application of a straightforward MLP, for which the cost function is a function of both the network output, in addition to another value calculated from the network weights (actually the partial derivative of the output with respect to one of the inputs).

Are there any flexible NN packages where I can code this? The only ones I've seen (Keras, nnet in R) require that the cost function is just parameterised by the network output and the target value.

$\endgroup$
1
$\begingroup$

You should be able to do that in Keras, actually you should be able to do that in almost any flexible package. For example regularization does exactly that, it adds a penalty term to your loss function that punishes high weights.

| improve this answer | |
$\endgroup$
  • $\begingroup$ According to the docs keras.io/losses the loss functions are just parameterised by the network outputs and the target vector. You're right in that regularizers keras.io/regularizers accept the weight matrix, but they return a penalty that is additive to the loss function. I want to multiply the network output by another function of the inputs and network weights $\endgroup$ – Stuart Lacy Jun 2 '17 at 7:59
  • $\begingroup$ This should also be possible in Keras but I don't have a lot of experience with this. I honestly would look at more flexible packages like TensorFlow or PyTorch if you need this type of expressiveness $\endgroup$ – Jan van der Vegt Jun 2 '17 at 8:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.