0
간단한 예제에서 tf.estimator.LinearRegressor를 사용하려고합니다. 입력 점은 y = 2x 선에 있지만 추정자는 잘못된 값을 예측합니다. 여기 내 코드는 다음과 같습니다.LinearRegressor를 사용하려고 시도합니다.
# Create feature column and estimator
column = tf.feature_column.numeric_column("x", shape=[1])
lin_reg = tf.estimator.LinearRegressor([column])
# Train the estimator
train_input = tf.estimator.inputs.numpy_input_fn(
x={"x": np.array([1.0, 2.0, 3.0, 4.0, 5.0])},
y=np.array([2.0, 4.0, 6.0, 8.0, 10.0]), shuffle=False)
lin_reg.train(train_input)
# Make two predictions
predict_input = tf.estimator.inputs.numpy_input_fn(
x={"x": np.array([1.9, 1.4], dtype=np.float32)},
num_epochs=1, shuffle=False)
results = lin_reg.predict(predict_input)
# Print result
for value in results:
print(value['predictions'])
적절한 출력은 3.8과 2.8이어야하지만 예상치는 0.58과 0.48을 예측합니다. 이견있는 사람?
그것은 많은 도움이되었습니다. 감사 ! – user934904