0

For the custom activation function that changes to scores below, I want to replace the values with the activated_x with less than threshold=0.5 to be 0.

How can I modify?

def ScoreActivationFromSigmoid(x, target_min=1, target_max=9) :
    activated_x = K.sigmoid(x)
    #threshold = 0.5
    #binary_activated_x = activated_x > threshold
    #activated_x = K.cast_to_floatx(binary_activated_x)
    score = activated_x * (target_max - target_min) + target_min
    return  score

with the commented out source above, it is working as an activation function but when I uncomment them, they will not work

Isaac Sim
  • 539
  • 1
  • 7
  • 23

1 Answers1

0

The method K.cast_to_floatx operates on numpy arrays, not on tensors. You can instead use the function K.cast as follows:

activated_x = K.cast(binary_activated_x, dtype='float32')
Anna Krogager
  • 3,528
  • 16
  • 23