您好,我的训练数据中标签中有很多缺失值,例如单个标签可以具有以下值:
[nan, 0, 0, nan, 1, 0]
Run Code Online (Sandbox Code Playgroud)
我想训练一个忽略 nan 值的分类模型。目前我已将 nan 值填充为 -1,并尝试对其进行切片。掩码不起作用,因为分类交叉熵仍然考虑到它
ix = tf.where(tf.not_equal(y_true, -1))
true = tf.gather(y_true, ix)
pred = tf.gather(y_pred, ix)
return keras.objectives.categorical_crossentropy(true, pred)
Run Code Online (Sandbox Code Playgroud)
是我到目前为止所能想到的,但它有错误
InvalidArgumentError (see above for traceback): Incompatible shapes: [131] vs. [128]
[[Node: mul_1 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](Mean, _recv_dense_3_sample_weights_0/_13)]]
Run Code Online (Sandbox Code Playgroud)
有谁知道如何处理这个问题?
python missing-data keras tensorflow multiclass-classification