我是张量流量及其估算器的新角色。我尝试使用其DNNRegressor来拟合sin函数生成的数据。但是,它不起作用,似乎回归器无法工作。如果有经验的研究人员或工程师能给我一个答案,我将不胜感激。非常感谢!
import tensorflow as tf;
import numpy as np;
x = np.arange(100);
y = np.sin(x);
feature_column = tf.feature_column.numeric_column("variable");
train_input_fn = tf.estimator.inputs.numpy_input_fn(x = {"variable":x}, y=y, num_epochs = None, shuffle=True);
test_input_fn = tf.estimator.inputs.numpy_input_fn(x = {"variable":x}, num_epochs = 1, shuffle=False);
estimator = tf.estimator.DNNRegressor([50,50], feature_columns=[feature_column]);
estimator.train(input_fn=train_input_fn, steps = 1000);