1

I want to get the output of a keras layer which is a tensor of images, convert it to numpy arrays and apply a custom function on them without using backend functions, and return the output to the model. So it would be something like this:

def sum(args):
    # convert args to numpy arrays
    ???
    #calculating sum of all the elements
    s=np.sum(args)
    return s

Thank you very much for your help.

1 Answer 1

1

You can use the following format using Keras on Tensorflow:

  x = layers.Conv2D(32, (3, 3), strides=(1, 1), 
    padding='same', name='conv_1', use_bias=False)(input_image)
  x = my_function(x)
  x = layers.BatchNormalization(name='norm_1')(x)
Sign up to request clarification or add additional context in comments.

1 Comment

It doesn't work like that. I already tried it. InvalidArgumentError: You must feed a value for placeholder tensor 'input_19' with dtype float and shape [?,100] [[Node: input_19 = Placeholder[dtype=DT_FLOAT, shape=[?,100], _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.