[英]Uber Ludwig: Issue Making Predictions
我決定再次與 Uber Ludwig 打交道。 我想使用 python API 來做一個簡單的演示,它學習在輸入數字上加 1。 我已經成功生產了一個model,但是在預測的時候出現了問題。 我在 CPU TensorFlow 上的 PopOS 19.10 上運行 github 的最新版本。 感謝您的任何幫助。
編輯:我也復制了 windows 上的問題。
錯誤如下
Traceback (most recent call last):
File "predict.py", line 3, in <module>
x = model.predict({"numberIn":[1]}, return_type='dict')
File "/home/user/.local/lib/python3.7/site-packages/ludwig/api.py", line 914, in predict
gpu_fraction=gpu_fraction,
File "/home/user/.local/lib/python3.7/site-packages/ludwig/api.py", line 772, in _predict
self.model_definition['preprocessing']
File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 159, in build_data
preprocessing_parameters
File "/home/user/.local/lib/python3.7/site-packages/ludwig/data/preprocessing.py", line 180, in handle_missing_values
dataset_df[feature['name']] = dataset_df[feature['name']].fillna(
AttributeError: 'list' object has no attribute 'fillna'
這是我的預測腳本
from ludwig.api import LudwigModel
model = LudwigModel.load("/home/user/Documents/ludwig-test/plus1/results/api_experiment_run_0/model")
x = model.predict({"numberIn":[1]}, return_type='dict')
#x = model.predict({"numberIn":[1]}, return_type=<class 'dict'>) I tried this with no success
print(x)
這是我的訓練腳本的內容。
mydata = {"numberIn":[], "value":[]}
for x in range(10000):
mydata["numberIn"].append(x)
mydata["value"].append(x + 1)
from ludwig.api import LudwigModel
print("Imported Ludwig")
modelobject = LudwigModel(model_definition_file="modeldef.yaml")
stats = modelobject.train(data_dict=mydata)
modelobject.close()
型號def.yaml
input_features:
-
name: numberIn
type: numerical
output_features:
-
name: value
type: numerical
解決方案: predict function 的輸入參數不是位置的,在這種情況下需要指定data_dict
。 x = modelobject.predict(data_dict=mydictionary)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.