keras-team / keras

Deep Learning for humans
http://keras.io/
Apache License 2.0
61.63k stars 19.42k forks source link

no keras history of tensor, and impossible to make it a Input #10544

Closed suchen-sci closed 3 years ago

suchen-sci commented 6 years ago

Hi all,

I am applying the paper of Semi-supervised Learning with Deep Generative models.

Here is the problem, i have a classifier, who produce a softmax probability (10 dimension vector for 10 classes), so for every class, i need to embed to onehot version vector into the decoder model. The model is a little complicated, so here i put the simply version of it.

x = Input((batch,784)) # this the mnist data input z = encoder(x) # encoder model to produce latent variable z c = classifier(x) # classifier to produce softmax probability for digit 0-9 onehot # this is onthot tensor with dimension of 10 by 10 for i in range(10): f_x(i) = decoder(z, onehot(i)) # here we put different onehot into the network then we calculate the loss for 10 different classes and total loss will be: K.sum(c * losses)

So, we problem is for the decoder part, my input of onehot always cause problem of no keras history. and i also try decoder(z, Input(tensor=onehot(i)) but it says graph disconnected, so can anyone help me with this problem?

Best wishes,

Chen

suchen-sci commented 6 years ago

can anyone provide some possible way to achieve this?