Categories
Misc

How to use numpy functions in tensorflow custom loss?

I am trying to design a model to minimize the output value of a certain function which takes an input array and performs certain math operations with each elements of the input array and returns a final result. I have written this function using numpy and am trying to define a loss like –

function = function_using_numpy(input_array) #returns scalar float

loss_function(truth, prediction):

loss = k.abs(function(truth) – function (prediction))

return loss

The problem is tensorflow cannot convert a tensor to numpy array to compute the loss. Is the a way around this? Would be grateful for some pointers. Thanks in advance

submitted by /u/LatePenguins
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.