我正在使用LinearClassifier,一个罐装估算器(https://www.tensorflow.org/api_docs/python/tf/estimator/LinearClassifier)来获取我拥有的样本数据集。一切似乎都运行良好,但不确定为什么它不会收敛。基本上损失只是一直跳跃但不会下降直到稳定状态
代码非常简单:
def create_train_input_fn(x_train, y_train):
return tf.estimator.inputs.pandas_input_fn(
x=x_train,
y=y_train,
batch_size=16,
num_epochs=3,
shuffle=True)
train_input = create_train_input_fn(df_x_train, y_train)
### Define the feature columns------------------------
# Generate the numeric column names
num_columns_dict = {'ios_flag': tf.int32,
'homescreen': tf.int32,
'view_listing':tf.int32,
'view_product':tf.int32,
'search': tf.int32,
'add_to_cart': tf.int32,
'guest_sale': tf.int32,
'sale': tf.int32}
# Generate the feature columns
num_list_temp = []
for keys, values in num_columns_dict.iteritems(): #current and next loop
num_list_temp.append(
tf.feature_column.numeric_column(key=keys, dtype=values))
print(num_list_temp)
##### running the linear estimator model-----------------------------------------
## Initialize standard linear model
model_dir="/Users/singkwan/OneDrive - Lazada Group/app_quality_score/v2/tf_checkpoints/qs_linear_2/"
m_linear = tf.estimator.LinearClassifier(feature_columns=num_list_temp,
optimizer=tf.train.GradientDescentOptimizer(
learning_rate=0.01
),
model_dir=model_dir)
# Train the Linear Model.
m_linear.train(input_fn=train_input)
数据非常简单,都是数字列。我测试了一些其他的东西,但没有解决它:
也许它不是一个具体的编码问题,但是因为如果有人有一些见解它应该是好的