小编Dav*_*ord的帖子

在 Tensorflow 2.X 中测量 TFLite 模型的触发器

我正在尝试测量 TF2 中 TFLite 模型的 FLOPS。我知道 Tensorflow 1.x 有 tf.profiler,它对于测量失败非常有用。它似乎与 tf.keras 配合得不好。

有人可以描述一下如何测量 TF2 中 TFLite 模型的 FLOP 吗?我似乎无法在网上找到答案。非常感谢大家抽出宝贵的时间。

编辑:下面评论的链接对 tflite 没有帮助。

python machine-learning keras tensorflow tensorflow2.0

5
推荐指数
1
解决办法
2258
查看次数

Pytorch 模型优化:自动混合精度与量化?

我正在尝试优化我的 pytorch 模型。我了解量化的基础知识(将 32 位浮点数更改为 16 位或 8 位的其他数据类型),但我不知道这两种方法有何不同或应选择什么。

我看到 AMP(自动混合精度)https://pytorch.org/tutorials/recipes/recipes/amp_recipe.html 和常规量化https://pytorch.org/tutorials/recipes/quantization.html

有人可以解释一下区别和应用吗?谢谢。

optimization pytorch

5
推荐指数
1
解决办法
1340
查看次数

如何在tensorflow 2 (tf.keras)中进行空洞卷积

我正在尝试将一些代码从tensorflow 1.x 转换为tensorflow 2.x。到目前为止进展顺利,但我陷入了空洞卷积。与其他层不同,似乎没有一对一的转换。

到目前为止,我已经将所有内容统一到 tf.keras。这里有一个纯 keras 实现和一个 tf.nn.atrous_conv2d 实现,我也不确定是否可以在 tf.keras.Model 功能 api 中使用它们。

这是代码:

with tf.variable_scope('aconv1d_' + name):
        shape = [None, 30, 128]
        kernel = tf.get_variable('kernel', (1, size, shape[-1], n_filters), dtype=tf.float32,
                                 initializer=tf.contrib.layers.xavier_initializer())
        if bias:
            b = tf.get_variable('b', [shape[-1]], dtype=tf.float32, initializer=tf.constant_initializer(0))
        out = tf.nn.atrous_conv2d(tf.expand_dims(input_tensor, dim=1), kernel, rate=rate, padding='SAME') + (
            b if bias else 0)
        out = tf.squeeze(out, [1])

        return out
Run Code Online (Sandbox Code Playgroud)

我只想转换它,将其粘贴到 keras 功能 api 中,执行 model.fit,然后运行。

谢谢你帮助我这样的菜鸟。

machine-learning keras tensorflow tf.keras tensorflow2.0

3
推荐指数
1
解决办法
2387
查看次数