from_tensor_slices()接受1个位置参数,但给了2个错误

时间:2020-07-30 21:03:56

标签: tensorflow2.0

曾经处理线性回归问题,但我一直遇到相同的错误。

def make_input_fn(data_df, label_df, num_epochs=10, shuffle=True, batch_size=32):
    def input_function():
        ds = tf.data.Dataset.from_tensor_slices(dict(data_df), label_df)
        if shuffle:
            ds = ds.shuffle(1000)
        ds =ds.batch(batch_size).repeat(num_epochs)
        return ds
    return input_function

train_input_fn = make_input_fn(dftrain, y_train)
eval_input_fn  = make_input_fn(dfeval, y_eval, num_epochs=1, shuffle=False)


linear_est = tf.estimator.LinearClassifier(feature_columns=feature_columns)

linear_est.train(train_input_fn)
result = linear_est.evaluate(eval_input_fn)

clear_output()
print(result)
TypeError: from_tensor_slices() takes 1 positional argument but 2 were given

0 个答案:

没有答案