你能用Caffe在同一数据上训练多个网络吗?

时间:2016-02-16 15:49:05

标签: python neural-network gpu deep-learning caffe

我正在编写一个校准管道来学习神经网络的超参数,以检测DNA序列的特性*。因此,这需要在具有不同超参数的相同数据集上训练大量模型。

我正在尝试优化它以在GPU上运行。与图像数据集相比,DNA序列数据集非常小(通常4个通道中的10s或100s碱基对代表4个DNA碱基,A,C,G和T,与3个RGB通道中的10,000个像素相比) ,因此无法在GPU上充分利用并行化,除非同时训练多个模型。

有没有办法在Python中用Caffe做到这一点?

(我之前asked this question提到在nolearn,lasagne或Theano中这样做,但我不确定它是否可能因此转移到Caffe。)

*它基于DeepBind model来检测转录因子与DNA结合的位置,如果您有兴趣的话。

2 个答案:

答案 0 :(得分:2)

Yes. The following options are available for this.

Option 1: Parallel training processes. Write a network definition for each hyper-parameter configuration and run a training process for each.

Pros: No need to manage resources yourself. Cons: If all networks are working off of the same data, you'll be paying the cost of data copy from CPU to GPU RAM multiple times. This can get highly redundant. I've noticed this slowing down so much that I might as well have trained the different network sequentially.

Option 2: Merge different network definitions into a single prototxt and train with a single solver. The layer and blob names have to be unique for the sub-networks to be independent.

This ipython notebook provides a demo of this. The merging of networks into the prototxt for you. The notebook also demonstrates that by keeping the layer and blob names unique fo each sub network, the combined training process will reach the same results as if you trained each independently.

答案 1 :(得分:0)

也许我没有理解这个问题,但是要在任何框架上训练多个网络,你必须为每次训练运行一个不同的过程(如果你有多个GPU,设置标志,以便每个价格使用一个不同的一个)。

使用一个GPU,在图像分类中我们通常遇到的主要问题是内存不足(显而易见的一部分),但假设你没有这个,你应该可以在同一个GPU上运行两个训练。由于GPU中进程之间的上下文切换,您的训练性能会慢下来。根据我的经验,这种减速速度是x2-x4的因素,所以通常不值得(但无论如何都要检查)。