【神经网络实践】tentorflow上的多目标识别(3)

前言:

{

    这次也遇到了不少问题,最头疼的就是OOM(内存不够)。虽然要训练的东西很少,但在初始化时还是会出错,目前就先用CPU(禁用显存)做初步调试。

}

 

正文:

{

    按照我原本的打算,损失是mean_squared_error;当某类的输出与标签的差不小于0.5时,则此类的预测正确,准确率为平均正确率。

    此准确率的计算用到了二值张量。代码1是张量二值化的函数和评估步骤,其中输出张量input_tensor的类型需要与阈值threshold的一致。

#代码1
#the following function is to return a binary tensor by the argument input_tensor 
#of which values less than the threshold will be converted into zeros or Falses.
def tensor_binaryzation(input_tensor, threshold):
    y = tf.subtract(tf.cast(threshold, tf.float32), 1.0)
    x = tf.cast(input_tensor, tf.float32)
    output_tensor = tf.cast(tf.subtract(x, y), dtype=tf.uint64)
    return tf.cast(output_tensor, dtype=tf.bool)

 

    如果想改变trainable variables&#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值