1

I want to implement a custom loss function, I read the following links

But when I return the following in the metric function

K.sum(y_true)

it returns a float value.

My label values are all integrals, so why is their sum coming as float value?

user5722540
  • 590
  • 8
  • 24
  • They are probably being cast to floats somewhere, as neural networks take floating point numbers as inputs. – Dr. Snoopy Feb 13 '18 at 13:05
  • But all my labels are integer value: 1, 0 – user5722540 Feb 13 '18 at 13:19
  • Yes, but keras probably cast them. So you're label 1 will give 1.0 and 0 will give 0.0 – Pusheen_the_dev Feb 13 '18 at 13:25
  • The loss is a continuous value in the end, so at some point they will be cast to float. – Dr. Snoopy Feb 13 '18 at 13:27
  • Oh okay. But even if it is 1.0 and 0.0 how can their sum be 983.1287? – user5722540 Feb 13 '18 at 14:22
  • Have you tried printing np.sum(y) where y is your training data set? If your training data are all integers, this should be an integer. I'd recommend including a small subset of your training labels (y values) in the question. You should also describe in more detail the network architecture (easiest just to include the code). – T3am5hark May 12 '18 at 21:42

0 Answers0