zoukankan      html  css  js  c++  java
  • MACE移植要求

    MACE支持Tensorflow的depth_to_space和space_to_depth,以及strided_slice算子。

    其中depth_to_space可以用来无平滑地进行上采样。

    space_to_depth无损地下采样。

    strided_slice一般采用tensor[index_a : index_b]的方式使用,但stride_slice很不成熟,最好不用,采用掩膜(mask)相乘的方式来计算

    tf.reduce_mean在MACE中不支持channel axis的合并

    tf.minimum不支持,但可以用-(tf.maximum(-x, w))来实现

    MACE在GPU上不支持MatMul,所以只能采用tf.nn.conv2d来实现全连接。如下:

    def gray_world_balance(x):
        mean_ = tf.maximum(tf.reduce_mean(x, axis=(1, 2), keepdims=True), 1e-6)
        print(mean_.shape)
        kernel = np.array([[[[0.333333, 0.333333, 0.333333, 0.333333],
                             [0.333333, 0.333333, 0.333333, 0.333333],
                             [0.333333, 0.333333, 0.333333, 0.333333],
                             [0.0, 0.0, 0.0, 0.0]]]], dtype=np.float32)
        w_ = tf.constant(kernel, dtype=tf.float32)
        print(w_.shape)
        global_mean_ = tf.nn.conv2d(input=mean_, filter=w_, strides=(1, 1, 1, 1), padding='VALID')
        print(global_mean_.shape)
        ratio_ = global_mean_ / mean_
        print(ratio_.shape)
        return -tf.maximum(-x * ratio_, -1.0)
  • 相关阅读:
    管理ceph缓存池
    Ceph更换OSD磁盘
    crushmap磁盘智能分组
    Angular 初体验
    音视频开发-FFmpeg
    开源项目OEIP 游戏引擎与音视频多媒体(UE4/Unity3D)
    Yolov3代码分析与训练自己数据集
    整合Yolov3到UE4/Unity3D
    CUDA版Grabcut的实现
    CUDA加opencv复现导向滤波算法
  • 原文地址:https://www.cnblogs.com/thisisajoke/p/10455837.html
Copyright © 2011-2022 走看看