简体   繁体   English

Keras 模型中有 2 个输出,但只有一个有缺失值?

[英]2 outputs in Keras model but only one with missing value?

I'd like to model two variables simultaneously using the same features at the input layer (a feed-forward network), but there are missing values in one of them .我想在输入层(前馈网络)使用相同的特征同时对两个变量进行建模,但其中一个缺少值。 I'm wondering if there is a way to mask the missing values when computing loss functions in Keras, bacause I don't want to delete Target 1 values at the index of missing Taregt 2 values during preprocessing.我想知道在 Keras 中计算损失函数时是否有办法掩盖缺失值,因为我不想在预处理期间删除缺失 Taregt 2 值索引处的 Target 1 值。

在此处输入图片说明

You can do some data processing and either drop the NaN values or fill them with the average value.您可以进行一些数据处理,然后删除 NaN 值或用平均值填充它们。 You can have a look at this https://towardsdatascience.com/data-preprocessing-concepts-fa946d11c82你可以看看这个https://towardsdatascience.com/data-preprocessing-concepts-fa946d11c82

As of now, I found that the best answer can be lumping two outputs into one and add an extra one-hot code to inputs to include whether the output is target 1 or 2. I found it works great for my study.到目前为止,我发现最好的答案是将两个输出合并为一个,并在输入中添加一个额外的one-hot 代码,以包括输出是目标 1 还是目标 2。我发现它对我的研究非常有用。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM