我尝试在pyspark中使用深度学习,但没有效果。
下面是我代码:
featurizer = DeepImageFeaturizer(inputCol="image",
outputCol="features",
modelName="InceptionV3")
lr = LogisticRegression(maxIter=5, regParam=0.03,
elasticNetParam=0.5, labelCol="label")
sparkdn = Pipeline(stages=[featurizer, lr])
spark_model = sparkdn.fit(train)
错误的最后一部分:
File ~/anaconda3/lib/python3.9/site-packages/sparkdl/transformers/keras_applications.py:45, in KerasApplicationModel.getModelData(self, featurize)
44 def getModelData(self, featurize):
---> 45 sess = tf.Session()
46 with sess.as_default():
47 K.set_learning_phase(0)
AttributeError: module 'tensorflow' has no attribute 'Session'
我试图卸载并安装tf.另外,我正在运行pyspark与深度学习包:
pyspark --packages databricks:spark-deep-learning:0.1.0-spark2.1-s_2.11
1条答案
按热度按时间wr98u20j1#
您似乎正在尝试使用
spark-deep-learning package
中的DeepImageFeaturizer
转换器。如果您的系统上安装了旧版本的TensorFlow,或者您使用的TensorFlow版本与spark-deep-learning package
不兼容,则通常会发生此错误。请尝试以下操作:
使用
pip uninstall tensorflow
卸载当前版本的TensorFlow。然后安装最新版本的TensorFlow:
pip install tensorflow
.确保您使用的TensorFlow版本与
spark-deep-learning package
兼容。根据文档,它需要TensorFlow 1.6或更高版本。运行代码之前,请尝试将环境变量
TF_CPP_MIN_LOG_LEVEL
设置为3。这有助于抑制某些TensorFlow警告和错误。