一种快速数据处理和ml模型训练框架
batchflow的Python项目详细描述
批处理流
BatchFlow
帮助您方便地处理随机或连续的数据批
定义数据处理和机器学习工作流,即使是不适合内存的数据集。
有关详细信息,请参见the documentation and tutorials。
主要功能:
-
柔性批生成< < /LI>
- 确定性和随机性管道
- 数据集和管道连接和合并
- 数据处理操作 柔性模型配置
- 批内并行性
- 批预取
- 准备使用ML模型和经验证的NN体系结构
- 方便的图层和帮助器功能可用于构建自定义模型
- 具有并行模型训练和扩展实验日志的强大研究引擎。
基本用法
my_workflow=my_dataset.pipeline().load('/some/path').do_something().do_something_else().some_additional_action().save('/to/other/path')
这里的诀窍是所有的处理操作都是惰性的。在需要它们的结果之前(例如,当您请求预处理批处理时),不会执行它们:
my_workflow.run(BATCH_SIZE,shuffle=True,n_epochs=5)
或
forbatchinmy_workflow.gen_batch(BATCH_SIZE,shuffle=True,n_epochs=5):# only now the actions are fired and data is being changed with the workflow defined earlier# actions are executed one by one and here you get a fully processed batch
或
NUM_ITERS=1000foriinrange(NUM_ITERS):processed_batch=my_workflow.next_batch(BATCH_SIZE,shuffle=True,n_epochs=None)# only now the actions are fired and data is changed with the workflow defined earlier# actions are executed one by one and here you get a fully processed batch
训练神经网络
BatchFlow
包括准备好使用的成熟架构,如vgg、inception、resnet和许多其他架构。
要将它们应用于数据,只需选择一个模型,指定输入(如类或图像形状的数量)
打电话给train_model
。当然,如果需要,还可以选择loss函数、优化器和许多其他参数。
frombatchflow.models.tfimportResNet34my_workflow=my_dataset.pipeline().init_model('dynamic',ResNet34,config={'inputs/images/shape':B('image_shape'),'labels/classes':10,'initial_block/inputs':'images'}).load('/some/path').some_transform().another_transform().train_model('ResNet34',images=B('images'),labels=B('labels')).run(BATCH_SIZE,shuffle=True)
有关更高级的案例和详细的api,请参见the documentation。
安装
BatchFlow
module is in the beta stage. Your suggestions and improvements are very welcome.
BatchFlow
supports python 3.5 or higher.
稳定的python包
用现代的pipenv
pipenv install batchflow
用老式的pip
pip3 install batchflow
开发vesrion
用现代的pipenv
pipenv install git+https://github.com/analysiscenter/batchflow.git#egg=batchflow
用老式的pip
pip3 install git+https://github.com/analysiscenter/batchflow.git
之后,只需输入batchflow
:
importbatchflowasbf
git子模块
在许多情况下,将batchflow
作为子模块安装在项目存储库中可能比作为python包安装更方便。
git submodule add https://github.com/analysiscenter/batchflow.git
git submodule init
git submodule update
如果python文件位于另一个目录中,则可能需要添加一个路径到batchflow
:
importsyssys.path.insert(0,"/path/to/batchflow")importbatchflowasbf
使用子模块的好处是,项目中的每个提交都可以链接到它自己的子模块提交。 在快节奏的研究环境中,这是非常方便的。
也可以进行相对导入:
from.batchflowimportDataset
引用批处理流
如果有助于您的研究,请在您的出版物中引用batchflow。
Roman Khudorozhkov et al. BatchFlow library for fast ML workflows. 2017. doi:10.5281/zenodo.1041203
@misc{roman_kh_2017_1041203,
author = {Khudorozhkov, Roman and others},
title = {BatchFlow library for fast ML workflows},
year = 2017,
doi = {10.5281/zenodo.1041203},
url = {https://doi.org/10.5281/zenodo.1041203}
}