我使用来自https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/examples/learn/wide_n_deep_tutorial.py的教程代码,并且代码工作正常,直到我尝试做出预测而不是仅仅对其进行评估。我试图制作另一个看起来像这样的函数(只需删除参数y):
def input_fn_predict(data_file, num_epochs, shuffle):
"""Input builder function."""
df_data = pd.read_csv(
tf.gfile.Open(data_file),
names=CSV_COLUMNS,
skipinitialspace=True,
engine="python",
skiprows=1)
# remove NaN elements
df_data = df_data.dropna(how="any", axis=0)
labels = df_data["income_bracket"].apply(lambda x: ">50K" in x).astype(int)
return tf.estimator.inputs.pandas_input_fn( #removed paramter y
x=df_data,
batch_size=100,
num_epochs=num_epochs,
shuffle=shuffle,
num_threads=5)
Run Code Online (Sandbox Code Playgroud)
并这样称呼它:
predictions = m.predict(
input_fn=input_fn_predict(test_file_name, num_epochs=1, shuffle=True)
)
for i, p in enumerate(predictions):
print(i, p)
Run Code Online (Sandbox Code Playgroud)
{'概率':数组([0.78595656,0.21404342],dtype = float32),'登录':数组([-1.3007226],dtype = float32),'类':数组(['0'],dtype = object) ,'class_ids':array([0]),'logistic':array([0.21404341],dtype = float32)}
我该怎么读?
我最近刚切换到Mac。由于某些原因,我需要安装3.0版(确切地说是3.0版)的gradle。我可以使用安装gradle版本2.14 brew install homebrew/versions/gradle214,但不能对3.0版本进行同样的操作。有人能帮我吗?