nitishsrivastava / deepnet

Implementation of some deep learning algorithms.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About label prediction in evaluation of DBM

ParanoidHW opened this issue · comments

Hi! In the example of DBM model, it seems to me that both "input_layer" and "label_layer" are used as input data in evaluation, which bothers me a lot, because i think in the evaluation, you just put data into "input_layer" without labels, and then the net runs through some positive/negative phases and outputs the label predictions (and reconstructed input if necessary). Am i missing something here in the demo and code? Or have i totally misunderstood the procedure of DBM?

Here is the related(i think) lines in dbm.py, the Evaluation function:
"
def EvaluateOneBatch(self):
losses = self.PositivePhase(train=False, evaluate=True)
return losses
"

and then for PositivePhase, input_layer and label_layer are treated equally even in evaluation? :
"
def PositivePhase(self, train=False, evaluate=False, step=0):
# ...... some lines .........
for node in self.node_list:
if node.is_input:
# Load data into input nodes.
self.ComputeUp(node, train=train)

elif node.is_initialized:
# ..... some lines.....
if not self.cd or evaluate:
for node in self.input_datalayer:
self.ComputeUp(node, compute_input=True, step=step, maxsteps=self.train_stop_steps)

losses.append(node.GetLoss())
"
and for ComputeUp, the train tag seems to make no difference except dropout:
"
def ComputeUp(self, layer, train=False, compute_input=False, step=0,
maxsteps=0, use_samples=False, neg_phase=False):
Args:
train: True if this computation is happening during training, False during evaluation.
compute_input: If True, the state of the input layer will be computed. Otherwise, it will be loaded as data.
...
if layer.is_input and not compute_input:
layer.GetData()

else:
# .... some lines ......
"

well, is the demo DBM trained as generative model? how to train it as disciriminative model?

Yes, when training DBM, this demo use input_layer and label_layer as input.
They think when we can get visible and label data, why wouldn't we train it together?
However, in normal cases, to train a generative DBM model, you do not have label data, you should train the DBM without the label layer.
After the generative training procedure finished, you can turn the DBM model to a forward neural network(a discriminative model) and use the second layer as the augment input as DBM did.

@xcszbdnl Thank you very much.