问题描述
我正在使用databricks社区版上的sparkdl进行图像分类.我添加了所有的图书馆.我已经使用图像数据创建了数据框.
I'm doing image classification using sparkdl on databricks community edition.I added all the library's.i have created data-frame using the image data.
from pyspark.ml.classification import LogisticRegression
from pyspark.ml import Pipeline
from sparkdl import DeepImageFeaturizer
featurizer = DeepImageFeaturizer(inputCol="image", outputCol="features", modelName="InceptionV3")
lr = LogisticRegression(maxIter=20, regParam=0.05, elasticNetParam=0.3, labelCol="label")
p = Pipeline(stages=[featurizer, lr])
p_model = p.fit(train_df)
AttributeError Traceback (most recent call last)
<command-2468766328144961> in <module>()
7 p = Pipeline(stages=[featurizer, lr])
8
----> 9 p_model = p.fit(train_df)
/databricks/spark/python/pyspark/ml/base.py in fit(self, dataset, params)
62 return self.copy(params)._fit(dataset)
63 else:
---> 64 return self._fit(dataset)
65 else:
66 raise ValueError("Params must be either a param map or a list/tuple of param maps, "
/databricks/spark/python/pyspark/ml/pipeline.py in _fit(self, dataset)
104 if isinstance(stage, Transformer):
105 transformers.append(stage)
--> 106 dataset = stage.transform(dataset)
107 else: # must be an Estimator
108 model = stage.fit(dataset)
推荐答案
从您的问题的标题开始,听起来您好像遇到了 AttributeError:'ConsoleBuffer'对象没有属性'isatty'
Databricks Python笔记本中的错误.
From the title of your question, it sounds like you're hitting a AttributeError: 'ConsoleBuffer' object has no attribute 'isatty'
error in a Databricks Python notebook.
如果您使用的是 Databricks Runtime 3.3 或更高版本,错误应该得到解决.
If you are using Databricks Runtime 3.3 or later then this bug should be fixed.
在较早的Databricks Runtime版本中,您应该能够通过在Python笔记本的开头运行以下代码段来猴子修补 sys.stdout
来解决此问题:
In earlier Databricks Runtime releases, you should be able to work around this problem by monkeypatching sys.stdout
by running the following code snippet at the beginning of your Python notebook:
import sys
sys.stdout.isatty = lambda: False
sys.stdout.encoding = sys.getdefaultencoding()
Databricks的Python REPL覆盖了 sys.stdout
以使用我们自己的 ConsoleBuffer
类,并且在Databricks Runtime 3.3之前,该类未实现 isatty
和 encoding
方法.
Databricks' Python REPL overrides sys.stdout
to use our own ConsoleBuffer
class and prior to Databricks Runtime 3.3 this class did not implement the isatty
and encoding
methods.
来源:我是一位Databricks员工,致力于此错误修复.
Source: I'm a Databricks employee who worked on this bugfix.
这篇关于ConsoleBuffer"对象没有属性"isatty"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!