• 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)
  • 相关阅读:
    javascript编程——闭包概念
    Chromium源码编译和初步的代码阅读
    No Code 趋势小记
    Electron中require报错的解决与分析
    C# 值类型与引用类型
    C# 静态成员 和 实例成员
    C# 标识符 和 关键字
    C# 基础知识
    Taghepler
    JQuery 速查表
  • 原文地址:https://www.cnblogs.com/thisisajoke/p/10455837.html
Copyright © 2020-2023  润新知