【问题标题】:Error while running Systemml ,Can not import imap运行 Systemml 时出错,无法导入 imap
【发布时间】:2020-03-29 01:54:05
【问题描述】:

您好,我正在尝试在 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'

【问题讨论】:

  • 我也面临同样的问题。似乎 SystemML 与 Python3 尚不兼容。 imap 是一个 py2 函数。我什至尝试安装 systemml 1.3.0。不行。
  • 有没有办法在代码中忽略这个警告?还是强制使用地图?如果你发现了请告诉我
  • 我编辑了引发错误的脚本文件并将导入行替换为:stackoverflow.com/a/30271777/1578274,从而解决了这个问题。但随后在 SystemML 中遇到了其他 Py3 不兼容问题。

标签: python pyspark systemml


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-14
    • 2020-06-20
    相关资源
    最近更新 更多