我使用 Google Cloud Functions
将数据发送到 Cloud ML Engine
进行预测。
首先,我需要在将数据发送到 Cloud ML Engine
之前对其进行预处理。
为了预处理,我使用了两个分词器(来自 nltk
的 mwetokenizer 和来自 tensorflow
的 tf.keras.preprocessing.text.Tokenizer)。
当我将分词器加载到 Google Cloud Functions
时,我收到了一个错误:
ModuleNotFoundError: No module named ‘keras_preprocessing’
这是因为 nltk
和 tensorflow
不支持 Python 3.7。
问题:我该如何预处理数据并将其发送到 Cloud ML Engine
进行在线预测?
回答:
在这些库支持 Python 3.7 之前,你无法使用 Cloud Functions 完成此操作。你需要使用提供 Python 3.6 运行时的其他服务,例如 App Engine 灵活环境(它提供 Python 3.6.4)。