Home > Net >  How to avoid iteration custom keras layer
How to avoid iteration custom keras layer

Time:10-06

How would I write something in tensorFlow that would have the same result as

cnt = [tf.reduce_max(tf.divide(outs[i], self.b[1:, i])) for i in range(self.filters)]

This must be able to run on Graph execution, and I just need to increase the effeciency of this line.

CodePudding user response:

@tf.function
def func(**kwargs):
  cnt = [tf.reduce_max(tf.divide(outs[i], self.b[1:, i])) for i in range(self.filters)]
  return cnt

@tf.function uses the graph execution,

CodePudding user response:

I found that tf.reduce_max(tf.divide(outs, self.b[1:]), axis=1) works as intended.

  • Related