【发布时间】:2021-04-20 07:29:25
【问题描述】:
我有这个功能:
def sampling(x):
zeros = x*0
samples = tf.random.categorical(tf.math.log(x), 1)
samples = tf.squeeze(tf.one_hot(samples, depth=2), axis=1)
return zeros+samples
我从这一层调用:
x = layers.Lambda(sampling, name="lambda")(x)
但我需要更改 sampling 函数中的 depth 变量,所以我需要这样的东西:
def sampling(x, depth):
但是,我怎样才能使它与 Lambda 层一起工作?
非常感谢
【问题讨论】:
标签: python tensorflow machine-learning keras deep-learning