我正在尝试在 tensorflow 中构建一个线性分类器,下面是我的代码:
model = tf.estimator.LinearClassifier(
n_classes = 2,
model_dir = "ongoing",
feature_columns = categorical_features + continuous_features ///these are the feature columns
)
FEATURES = ['Age', 'Gender', 'ICD9Code']
LABEL = 'Condition'
def get_input_fn(data_set, num_epochs, n_batch, shuffle):
input = tf.compat.v1.estimator.inputs.pandas_input_fn(
x = pd.DataFrame({k: data_set[k].values for k in FEATURES}),
# x = data_dic,
y = pd.Series(data_set[LABEL].values),
batch_size = n_batch,
num_epochs = num_epochs,
shuffle = shuffle
)
return input
model.train(
input_fn = get_input_fn(csv_data, num_epochs = 40, n_batch = 10461, shuffle = False
),
steps = 1000
)
得到这样的终端,你能帮忙解决这个问题吗?谢谢!
附言我的 tensorflow 版本是 2.4.1