鸡尾酒食谱生成的条件变化自动编码器

时间:2018-05-08 13:54:19

标签: python function autoencoder activation softmax

我想使用条件变量自动编码器来生成鸡尾酒配方。我修改了this repo中的代码,以便它可以读取我自己的数据。输入是所有可能成分的数组,因此大多数条目的值为0.如果存在一种成分,则得到的值是标准化量为250 ml的值。最后一个指标是剩下的'剩下的'确保鸡尾酒总是增加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,与输入相似? 这是改变激活功能的问题吗?

谢谢:)

1 个答案:

答案 0 :(得分: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。你可以让它区分一个随机的鸡尾酒和一个真实的鸡尾酒。鸡尾酒。它将学会区分这两者,并且在此过程中,它将训练重量,以便能够创建一个能为您生成鸡尾酒的发电机!