1

您好我正在尝试在 IBMcloud 中使用 systemml 进行 keras 并行化,但是当我运行代码时:

sysml_model = Keras2DML(spark, keras_Model, input_shape=(1,1), weights='weights_dir', batch_size=batch_size, max_iter=max_iter, test_interval=0, display=10)

我得到 fowlloing 错误,你能帮我解决任何问题吗:

<ipython-input-20-772087af6a08> in <module>()
      4 samples = train.count()
      5 max_iter = int(epochs*math.ceil(samples/batch_size))
----> 6 sysml_model = Keras2DML(spark, keras_Model, input_shape=(1,1), weights='weights_dir', batch_size=batch_size, max_iter=max_iter, test_interval=0, display=10)
      7 sysml_model.fit(train[1], train[3])

/home/spark/shared/user-libs/python3.6/systemml/mllearn/estimators.py in __init__(self, sparkSession, keras_model, input_shape, transferUsingDF, load_keras_weights, weights, labels, batch_size, max_iter, test_iter, test_interval, display, lr_policy, weight_decay, regularization_type)
   1033         regularization_type: regularization type (default: "L2")
   1034         """
-> 1035         from .keras2caffe import convertKerasToCaffeNetwork, convertKerasToCaffeSolver, convertKerasToSystemMLModel
   1036         import tempfile, keras
   1037         if keras.backend.image_data_format() != 'channels_first':

/home/spark/shared/user-libs/python3.6/systemml/mllearn/keras2caffe.py in <module>()
     26 import os
     27 import math
---> 28 from itertools import chain, imap
     29 from ..converters import *
     30 from ..classloader import *

ImportError: cannot import name 'imap'
4

1 回答 1

0

imap 在 Python 3 的 itertools 模块中不再存在。您需要做的是使用 Python 3 内置的 2to3 包。所以您需要做的就是2to3 estimators.py在终端中。这将向您显示您需要对 estimators.py 文件进行的所有更改,以便它与 Python 3 兼容。如果您想将所有这些更改写入文件,只需执行2to3 -w estimators.py.

于 2020-12-03T04:21:47.023 回答