TensorLayer 基于TensorFlow的新型深度学习和强化学习库

程序名称:TensorLayer

授权协议: Apache

操作系统: 跨平台

开发语言: Python

TensorLayer 介绍

TensorLayer是一个基于TensorFlow的新型深度学习和强化学习库,专为研究人员和工程师而设计。
它提供了大量可自定义的神经层/功能,这些是构建真实AI应用程序的关键。 TensorLayer被ACM多媒体协会授予2017年最佳开源软件。

作为深度学习从业者,我们一直在寻找可以满足各种开发目的的库。 通过提供各种示例,教程和预先训练的模型,可以轻松采用该库。
此外,它允许用户轻松微调TensorFlow; 同时适合生产部署。 TensorLayer旨在满足所有这些目的。 它有三个主要特点:

  • 简单性:TensorLayer将TensorFlow的低级数据流接口提升到高级层/模型。 通过广泛社区提供的丰富示例代码,您可以轻松学习。
  • 灵活性:TensorLayer API是透明的:它不会屏蔽用户的TensorFlow; 但留下大量的钩子,有助于低级调整和深度定制。
  • 零成本抽象:TensorLayer可以实现TensorFlow的全部功能。 下表显示了使用TensorLayer和TITAN Xp上的原生TensorFlow的VGG16的训练速度。
















































    Mode

    Lib

    Data Format

    Max GPU Memory Usage(MB)

    Max CPU Memory Usage(MB)

    Avg CPU Memory Usage(MB)

    Runtime (sec)

    AutoGraph

    TensorFlow 2.0

    channel last

    11833

    2161

    2136

    74

    Tensorlayer 2.0

    channel last

    11833

    2187

    2169

    76

    Graph

    Keras

    channel last

    8677

    2580

    2576

    101

    Eager

    TensorFlow 2.0

    channel last

    8723

    2052

    2024

    97

    TensorLayer 2.0

    channel last

    8723

    2010

    2007

    95

    TensorLayer 是作为一个开发库来使用的。 其他包装库如Keras和TFLearn也提供高级抽象。
    然而,它们经常隐藏用户的底层引擎,这使得它们难以定制和微调。 相反,TensorLayer API通常是轻量级,灵活且透明的。
    用户经常会发现从示例和教程开始很容易,然后无缝地深入了解TensorFlow。
    此外,TensorLayer不会通过本机支持创建库锁定,以便从Keras导入组件。

    TensorLayer在北京大学,伦敦帝国理工学院,加州大学伯克利分校,卡内基梅隆大学,斯坦福大学,康涅狄格大学(UTC)以及谷歌,微软,阿里巴巴等公司等顶尖研究人员和工程师中的使用增长迅速。

    模型定义:

    静态模型:

    import tensorflow as tf
    from tensorlayer.layers import Input, Dropout, Dense
    from tensorlayer.models import Model
    
    def get_model(inputs_shape):
        ni = Input(inputs_shape)
        nn = Dropout(keep=0.8)(ni)
        nn = Dense(n_units=800, act=tf.nn.relu, name="dense1")(nn)
        nn = Dropout(keep=0.8)(nn)
        nn = Dense(n_units=800, act=tf.nn.relu)(nn)
        nn = Dropout(keep=0.8)(nn)
        nn = Dense(n_units=10, act=tf.nn.relu)(nn)
        M = Model(inputs=ni, outputs=nn, name="mlp")
        return M
    
    MLP = get_model([None, 784])
    MLP.eval()
    outputs = MLP(data)
    

    动态模型:

    class CustomModel(Model):
    
        def __init__(self):
            super(CustomModel, self).__init__()
    
            self.dropout1 = Dropout(keep=0.8)
            self.dense1 = Dense(n_units=800, act=tf.nn.relu, in_channels=784)
            self.dropout2 = Dropout(keep=0.8)#(self.dense1)
            self.dense2 = Dense(n_units=800, act=tf.nn.relu, in_channels=800)
            self.dropout3 = Dropout(keep=0.8)#(self.dense2)
            self.dense3 = Dense(n_units=10, act=tf.nn.relu, in_channels=800)
    
        def forward(self, x, foo=False):
            z = self.dropout1(x)
            z = self.dense1(z)
            z = self.dropout2(z)
            z = self.dense2(z)
            z = self.dropout3(z)
            out = self.dense3(z)
            if foo:
                out = tf.nn.relu(out)
            return out
    
    MLP = CustomModel()
    MLP.eval()
    outputs = MLP(data, foo=True) # controls the forward here
    outputs = MLP(data, foo=False)
    

TensorLayer 官网

https://gitee.com/TensorLayer/tensorlayer

相关编程语言

欧盟第7框架计划(FP7)的LarKC项目的目标是开发大规模...
Salad 是一种有效且灵活的实现著名的异常检测方法回...
multilanguage 是一个多语开发工具包,用于缓存多语...
go-cortex 是一个服务,通过倾听你的句子,并视图理...
DKPro Core 是基于 Apache UIMA 框架之上的自然语言...
NLTK 会被自然地看作是具有栈结构的一系列层,这些层...