Meine tensorflow Anwendung mit diesem Fehler abgestürzt:ADDN müssen die gleiche Größe und Form mit tf.estimator.LinearClassifier
Inputs to operation linear/linear_model/weighted_sum_no_bias of type AddN must have the same size and shape: Input 0: [3,1] != input 1: [9,1]
freuen, wenn mir jemand auf die Ursache verweisen.
Ich habe eine tfrecord
-Datei, die den folgenden Datensatz hat:
features {
feature {
key: "_label"
value {
float_list {
value: 1.0
}
}
}
feature {
key: "category"
value {
bytes_list {
value: "14"
value: "25"
value: "29"
}
}
}
feature {
key: "demo"
value {
bytes_list {
value: "gender:male"
value: "first_name:baerwulf52"
value: "country:us"
value: "city:manlius"
value: "region:us_ny"
value: "language:en"
value: "signup_hour_of_day:1"
value: "signup_day_of_week:3"
value: "signup_month_of_year:1"
}
}
}
}
Meine spec ist
{
'category': VarLenFeature(dtype=tf.string),
'_label': FixedLenFeature(shape=(1,), dtype=tf.float32, default_value=None),
'demo': VarLenFeature(dtype=tf.string)
}
Und mein tensorflow Code wie folgt:
category = tf.feature_column.categorical_column_with_vocabulary_list(key="category", vocabulary_list=["null", "14", "25", "29"],
demo = tf.feature_column.categorical_column_with_vocabulary_list(key="demo", vocabulary_list=["gender:male", "first_name:baerwulf52",
"country:us", "city:manlius", "region:us_ny",
"language:en", "signup_hour_of_day:1",
"signup_day_of_week:3",
"signup_month_of_year:1"])
feature_columns = [category, demo]
def get_input_fn(dataset):
def _fn():
iterator = dataset.make_one_shot_iterator()
next_elem = iterator.get_next()
ex = tf.parse_single_example(next_elem, features=spec)
label = ex.pop('_label')
return ex, label
return _fn
model = tf.estimator.LinearClassifier(
feature_columns=feature_columns,
model_dir=fp("model")
)
model.train(input_fn=get_input_fn(train_dataset), steps=100)
I sehen. Ich dachte, Tensorflow würde sie automatisch in 27 Datensätze aufteilen. Vielen Dank. – user8797249
@Mingxing gibt es einen bestimmten Grund für diese Einschränkung? Bedeutet das auch, dass LinearClassifiers [indicator_columns] (https://www.tensorflow.org/api_docs/python/tf/feature_column/indicator_column) oder [weighted_categorical_columns] (https://www.tensorflow.org/api_docs) nicht unterstützt/python/tf/feature_column/weighted_categorical_column)? – aarkay