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

标签 python tensorflow casting keras tensor

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

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

不过,K.cast 只允许转换为 float 。

我该如何解决这个问题?

最佳答案

这是你的做法:

casted = K.cast(yPred,"int32")

关于python - 将 KERAS 张量转换为 K.tf.int32,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50992946/

相关文章:

python - 运行时错误 : cuda runtime error (30) : unknown error at torch/csrc/cuda/Module. cpp:32

python - 如何在 tensorflow 中将字典转换为张量

python - 来自 Tensorflow 中的 sparse_softmax_cross_entropy_with_logits 的 NaN

python - 满足条件时终止所有进程

python - 使用sitk获取偏置场

python - Request.args 没有所有表单数据

javascript - typescript 键盘事件 : argument of type 'Event' is not assignable to parameter of type 'KeyboardEvent'

python - 按周划分 Pandas Dataframe

c - 为 union 分配内存以及 union 指针和指针 union 之间的区别

java - 在java中将整数数组转换为对象数组