简体   繁体   中英

How to avoid iteration custom keras layer

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.

@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,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM