我想使用条件变分自动编码器来生成鸡尾酒配方。我修改了此存储库中的代码,以便它可以读取我自己的数据。输入是所有可能成分的数组,因此大多数条目的值为 0。如果存在一种成分,它会得到一个值,即按 250 毫升标准化的量。最后一个索引是"剩余"的内容,以确保鸡尾酒始终将 op 加到 1。
例:
0,0.0,0.0,0.24,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.6,0.0,0.0,0.0,0.0,0.0,0.06,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.088,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0120000000000000
带有softmax激活函数的输出看起来有点像这样:
[5.8228267e-10 6.7397465e-10 1.9761790e-08 2.3713847e-01 3.1315527e-11
4.9592632e-11 4.2637563e-05 7.6098106e-10 2.9357905e-05 1.3291576e-08
2.6885323e-09 4.2986945e-10 3.0274603e-09 8.6994453e-11 3.2391853e-10
3.3694150e-10 4.9642315e-11 2.2861177e-10 2.5966980e-11 3.3872125e-10
4.8175470e-12 1.1207919e-09 7.8108942e-10 1.0438563e-09 4.7190268e-12
2.2692757e-09 3.3177341e-10 4.7493649e-09 1.6603904e-08 2.7854623e-11
1.1586791e-07 2.3917833e-08 1.0172608e-09 2.2049740e-06 4.0200213e-10
4.8334226e-05 1.9393491e-09 4.0731374e-10 4.5671125e-10 8.5878060e-10
1.3625046e-10 1.7755342e-09 2.4927729e-09 3.8919952e-09 1.6791472e-10
1.5160178e-09 9.0631114e-10 1.2043951e-08 2.1420650e-01 1.4531254e-10
3.9913628e-10 4.6368896e-06 6.8399265e-11 2.4654754e-09 6.5392605e-12
5.8443012e-10 2.7861690e-11 4.7215394e-08 5.1503157e-09 5.4484850e-10
1.9266211e-10 7.2835156e-09 6.4243433e-10 4.2432866e-09 4.2630177e-08
1.1281617e-12 1.8015703e-08 3.5657147e-10 3.4241193e-11 4.8394988e-10
9.6064046e-11 2.9857121e-02 3.8048144e-11 1.1893182e-10 5.1867032e-01]
如何确保值仅分布在几个成分中,而其余成分为 0,类似于输入? 这是更改激活函数的问题吗?
谢谢:)
我不确定你是否要在这里使用概率。您似乎正在回归到某些特定值。因此,不使用softmax并使用简单的均方误差损失是有意义的。
请注意,如果某些值在损失中总是有偏差,则可以对损失使用额外的权重,或使用一些抽象(例如 Keras 的class_weight
(。
对于此任务,您可以考虑使用 Keras,尤其是对于此任务,这将是有意义的。有一个示例签入到主控:https://github.com/keras-team/keras/blob/master/examples/variational_autoencoder.py
对于此任务,使用 GAN: https://github.com/keras-team/keras/blob/master/examples/mnist_acgan.py 实际上可能是有意义的。你可以让它区分随机鸡尾酒和"真正的"鸡尾酒。它将学会区分两者,并在此过程中训练重量,以便能够创建一个发电机,为您生成鸡尾酒!