本文介绍了SystemML:无法导入子模块mllearn(因此也将导入Keras2DML函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IBM Watson Studio(默认Spark python环境),并尝试将Keras模型转换为systemml DML并在Spark上进行训练.

I am using IBM Watson Studio (Default spark python environment) and trying to convert a Keras model to systemml DML and train it on Spark.

!pip install systemml 
import systemml

这执行得很好.但这-

from systemml import mllearn 

投掷SyntaxError:import *仅在模块级别允许

throwsSyntaxError: import * only allowed at module level

dir(systemml)

不显示mllearn.

doesn't show mllearn.

我尝试从 http://www安装它.romeokienzler.com/systemml-1.0.0-SNAPSHOT-python.tar.gz https://sparktc.ibmcloud.com/repo/latest/systemml-1.0.0-SNAPSHOT-python.tar.gz 和一个git克隆,但是没有成功.我在做什么错了?

I tried to install it from http://www.romeokienzler.com/systemml-1.0.0-SNAPSHOT-python.tar.gz and https://sparktc.ibmcloud.com/repo/latest/systemml-1.0.0-SNAPSHOT-python.tar.gzand a git clone but was unsuccessful. What am I doing wrong?

推荐答案

您需要执行dir(systemml.mllearn)才能查看mllearn函数.

You need to do dir(systemml.mllearn) to see mllearn functions.

>>> dir(systemml.mllearn)
['Caffe2DML', 'Keras2DML', 'LinearRegression', 'LogisticRegression', 
'NaiveBayes', 'SVM', '__all__', '__builtins__', '__doc__', '__file__', 
'__name__', '__package__', '__path__', 'estimators']

请从pypi.org安装SystemML 1.2.1.2是2018年8月以来的最新版本.1.0版仅具有实验性支持.

Please install SystemML 1.2 from pypi.org. 1.2 is the latest release from Aug. 2018. Release 1.0 only had experimental support.

能否请您仅尝试导入MLContext,以查看是否加载主SystemML jar文件是否有效,以及您的安装使用什么版本?

Can you please try to only import MLContext, just to see whether loading the main SystemML jar file works, and what version your installation uses?

>>> from systemml import MLContext
>>> ml = MLContext(sc)

Welcome to Apache SystemML!
Version 1.2.0

>>> print (ml.buildTime())
2018-08-17 05:58:31 UTC

>>> from sklearn import datasets, neighbors
>>> from systemml.mllearn import LogisticRegression

>>> y_digits = digits.target 
>>> n_samples = len(X_digits) 
>>> X_train = X_digits[:int(.9 * n_samples)] 
>>> y_train = y_digits[:int(.9 * n_samples)] 
>>> X_test = X_digits[int(.9 * n_samples):] 
>>> y_test = y_digits[int(.9 * n_samples):] 
>>> 
>>> logistic = LogisticRegression(spark)
>>> 
>>> print('LogisticRegression score: %f' % logistic.fit(X_train, y_train).score(X_test, y_test))
18/10/20 00:15:52 WARN BaseSystemMLEstimatorOrModel: SystemML local memory     budget:5097 mb. Approximate free memory available on the driver JVM:416 mb.
18/10/20 00:15:52 WARN StatementBlock: WARNING: [line 81:0] -> maxinneriter --     Variable maxinneriter defined with different value type in if and else clause.
18/10/20 00:15:53 WARN SparkExecutionContext: Configuration parameter     spark.driver.maxResultSize set to 1 GB. You can set it through Spark default configuration setting either to 0 (unlimited) or to available memory budget of size 4 GB.
BEGIN MULTINOMIAL LOGISTIC REGRESSION SCRIPT
...

这篇关于SystemML:无法导入子模块mllearn(因此也将导入Keras2DML函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 14:55