在 Google Colab 中使用 PyGAD 的并行处理进行神经网络训练时出现的错误

问题描述 投票:0回答:0

我正在尝试使用 PyGAD 来训练 Keras 顺序模型。目前,它可以很好地找到解决方案,但需要很长时间。

我已经在 keras 端使用了批处理,但是 PyGAD 会降低性能。为了让您了解情况,我使用了一百个人的总体,每个人大约有 500 个参数。每一代大约需要 10 秒,但运行神经网络 1600 个案例平均需要 30 毫秒。

我尝试使用

parallel_processing
属性,但我不断收到几个错误。有时我可以运行 3 到 5 代之后才出现错误。其他时候它只是冻结或立即给我一个错误。没有
parallel_processing
,没有错误。

我正在使用 Google Colab。我用过
!nohup
命令但是没用

这些是我遇到的错误:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-100-62b9b1c718aa> in <cell line: 1>()
----> 1 ga_instance.run()    # Executa o treinamento
      2 ga_instance.plot_fitness()   # Plota a evolução da fitness no decorrer das gerações

9 frames
/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   7260 def raise_from_not_ok_status(e, name):
   7261   e.message += (" name: " + name if name is not None else "")
-> 7262   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   7263 
   7264 

InvalidArgumentError: {{function_node __wrapped__StridedSlice_device_/job:localhost/replica:0/task:0/device:GPU:0}} Expected begin, end, and strides to be 1D equal size tensors, but got shapes [2], [1], and [1] instead. [Op:StridedSlice] name: strided_slice/
---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-38-62b9b1c718aa> in <cell line: 1>()
----> 1 ga_instance.run()    # Executa o treinamento
      2 ga_instance.plot_fitness()   # Plota a evolução da fitness no decorrer das gerações

12 frames
/usr/local/lib/python3.9/dist-packages/tensorflow/python/framework/ops.py in raise_from_not_ok_status(e, name)
   7260 def raise_from_not_ok_status(e, name):
   7261   e.message += (" name: " + name if name is not None else "")
-> 7262   raise core._status_to_exception(e) from None  # pylint: disable=protected-access
   7263 
   7264 

InvalidArgumentError: {{function_node __wrapped__Sum_device_/job:localhost/replica:0/task:0/device:GPU:0}} Invalid reduction dimension (-1 for input with 0 dimension(s) [Op:Sum]
python parallel-processing google-colaboratory genetic-algorithm pygad
© www.soinside.com 2019 - 2024. All rights reserved.