Skip to content
Advertisement

In Keras, can I use an arbitrary algorithm as a loss function for a network?

I has been trying to understand this machine learning problem for many days now and it really confuses me, I need some help.

I am trying to train a neural network whose input is an image, and which generates another image as output (it is not a very large image, it is 8×8 pixels). And I have an arbitrary fancy_algorithm() “black box” function that receives the input and prediction of the network (the two images) and outputs a float number that tells how good the output of the network was (calculates a loss). My problem is that I want to train THIS neural network but using the loss generated by the black box algorithm. This problem is confusing me, I researched a lot and I didn’t find much about it, it seems like reinforcement learning, but at the same time I’m not sure because it’s not like an agent, but it has some kind of reinforcement at the same time.

In case you need more details to help me just ask. Thanks in advance!

Advertisement

Answer

Alright question solved. This is a reinforcement learning problem. I can’t use a gradient based optimization on my black-box loss function which don’t has any gradient. More details here: https://www.reddit.com/r/tensorflow/comments/gekotd/can_i_use_an_arbitrary_algorithm_as_a_loss/

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement