TensorLayerX 是一个跨平台开发框架,可以运行在各类操作系统和AI硬件上,并支持混合框架的开发。目前支持TensorFlow、MindSpore、PaddlePaddle框架常用神经网络层以及算子,PyTorch支持特性正在开发中,支持列表。
设计特点
TensorLayerX相比于之前开发的 TensorLayer有着更加强大的功能,它兼容多种计算框架后端。
TensorLayer各个版本对比
TensorLayerX继承了之前版本的特性,包括简单性,灵活性和低级抽象。 TensorLayerX支持多后端,如TensorFlow, MindSpore, PaddlePaddle和PyTorch。
它允许用户在不同的硬件上运行相同的代码,比如Nvidia-GPU和HuaWei-Ascend。TensorLayerX的更多功能正在开发中。
-
模型库: 构建包含经典模型和sota模型的系列模型库,涵盖CV、NLP、RL等领域。
-
模型部署: TensorLayerX将支持ONNX协议,支持模型导出、导入和部署。
-
并行训练: 为了支持并行训练,数据并行已列入开发计划中。
快速使用
🔥🔥🔥🔥如果你使用OpenI进行模型调试、训练任务,可以使用配置好的tensorlayerx镜像。镜像已安装好tensorflow、mindspore、paddlepaddle、Pytorch,仅需再安装TensorLayerX即可快速体验 Code Once, Run Everywhere。镜像信息如下:
dockerhub.pcl.ac.cn:5000/user-images/openi:tensorlayerx
cuda 10.1
python 3.7
tensorflow 2.2.0
mindspore 1.8.1
torch 1.10
paddle 2.2.0
# install from pypi
pip3 install tensorlayerx
# install from Github
pip3 install git+https://git.openi.org.cn/OpenI/TensorLayerX.git
更多的安装详情可以参考 Installtion
你可以立即使用tensorlayerx来定义一个模型,在后台使用你最喜欢的框架,例如:
import os
os.environ['TL_BACKEND'] = 'tensorflow' # modify this line, switch to any framework easily!
#os.environ['TL_BACKEND'] = 'mindspore'
#os.environ['TL_BACKEND'] = 'paddle'
#os.environ['TL_BACKEND'] = 'torch'
import tensorlayerx as tlx
from tensorlayerx.nn import Module
from tensorlayerx.nn import Linear
class CustomModel(Module):
def __init__(self):
super(CustomModel, self).__init__()
self.linear1 = Linear(out_features=800, act=tlx.ReLU, in_features=784)
self.linear2 = Linear(out_features=800, act=tlx.ReLU, in_features=800)
self.linear3 = Linear(out_features=10, act=None, in_features=800)
def forward(self, x, foo=False):
z = self.linear1(x)
z = self.linear2(z)
out = self.linear3(z)
if foo:
out = tlx.softmax(out)
return out
MLP = CustomModel()
MLP.set_eval()
文档
TensorLayerX为初学者和专业人士提供了大量的文档。
使用例子
- 基础例子 for tutorials✅
- OpenIVA an easy-to-use product-level deployment framework✅
- TLXZoo pretrained models/backbones🚧
- TLXCV a bunch of Computer Vision applications🚧
- TLXNLP a bunch of Natural Language Processing applications🚧
- TLXRL a bunch of Reinforcement Learning applications, check RLZoo for the old version✅
联系方式
引用方式
如果你觉得TensorLayerX对你的项目有用,请引用以下文章:
@article{tensorlayer2017,
author = {Dong, Hao and Supratak, Akara and Mai, Luo and Liu, Fangde and Oehmichen, Axel and Yu, Simiao and Guo, Yike},
journal = {ACM Multimedia},
title = {{TensorLayer: A Versatile Library for Efficient Deep Learning Development}},
url = {http://tensorlayer.org},
year = {2017}
}
@inproceedings{tensorlayer2021,
title={TensorLayer 3.0: A Deep Learning Library Compatible With Multiple Backends},
author={Lai, Cheng and Han, Jiarong and Dong, Hao},
booktitle={2021 IEEE International Conference on Multimedia \& Expo Workshops (ICMEW)},
pages={1--3},
year={2021},
organization={IEEE}
}