将 KERAS 张量转换为 K.tf.int32

3 python casting keras tensorflow tensor

这是来自自定义 Keras 回调 casted=K.cast((yPred), K.tf.int32)

我绝对需要将 yPred(一个张量)转换为 int32 类型(该转换应用于张量内容,我知道)

尽管如此,K.cast 只允许转换为浮点数。

我该如何解决问题?

Dan*_*ler 5

这是你如何做到的:

casted = K.cast(yPred,"int32")
Run Code Online (Sandbox Code Playgroud)