Ejemplo n.º 1
0
 def visActProbs(self):
     GaussianRBM.visActProbs(
         self)  #now self.negVis holds the net input to the visible units
     #self.negVis has shape (self.numVis, self.mbsz)
     self.negVis.reshape((self.k, self.mbsz * self.numVis / self.k))
     singleSoftmax(self.negVis, self.tempRow)
     self.negVis.reshape((self.numVis, self.mbsz))
Ejemplo n.º 2
0
 def fprop(self):
     cm.dot( self.W.T, self.vis, target = self.hActProbs)
     self.hActProbs.add_col_vec(self.hidBias)
     
     self.U.copy_to_host()
     labHid = self.U.numpy_array
     Utrans = cm.CUDAMatrix(labHid.transpose())
             
     self.tempLabelMB.assign_scalar(0.0)
     self.tempLabelMB.add_col_vec(self.labBias)
     
     for c in range(self.numClasses): #183 of these
         self.discacchids[c].assign_scalar(0.0) #numHid by mbsz
         self.discacchids[c].add(self.hActProbs)
         self.discacchids[c].add_col_vec(Utrans.slice(c,c+1))
         self.tempHidMB.assign(self.discacchids[c])
         cm.exp(self.tempHidMB)
         self.tempHidMB.add_scalar(1.0)
         cm.log(self.tempHidMB)
         self.tempHidMB.sum(0, self.tempRow)
         self.tempLabelMB.set_row_slice(c,c+1, self.tempRow)
     #singleSoftmax(self.tempLabelMB, self.tempLabelCol, self.tempRow)
     singleSoftmax(self.tempLabelMB, self.tempRow)
     self.tempLabelMB.copy_to_host()
     self.acts = self.tempLabelMB.numpy_array.copy() #self.tempLabelMB.numpy_array #we may not need the copy here
     return self.acts
Ejemplo n.º 3
0
    def fprop(self):
        cm.dot(self.W.T, self.vis, target=self.hActProbs)
        self.hActProbs.add_col_vec(self.hidBias)

        self.U.copy_to_host()
        labHid = self.U.numpy_array
        Utrans = cm.CUDAMatrix(labHid.transpose())

        self.tempLabelMB.assign_scalar(0.0)
        self.tempLabelMB.add_col_vec(self.labBias)

        for c in range(self.numClasses):  #183 of these
            self.discacchids[c].assign_scalar(0.0)  #numHid by mbsz
            self.discacchids[c].add(self.hActProbs)
            self.discacchids[c].add_col_vec(Utrans.slice(c, c + 1))
            self.tempHidMB.assign(self.discacchids[c])
            cm.exp(self.tempHidMB)
            self.tempHidMB.add_scalar(1.0)
            cm.log(self.tempHidMB)
            self.tempHidMB.sum(0, self.tempRow)
            self.tempLabelMB.set_row_slice(c, c + 1, self.tempRow)
        #singleSoftmax(self.tempLabelMB, self.tempLabelCol, self.tempRow)
        singleSoftmax(self.tempLabelMB, self.tempRow)
        self.tempLabelMB.copy_to_host()
        self.acts = self.tempLabelMB.numpy_array.copy(
        )  #self.tempLabelMB.numpy_array #we may not need the copy here
        return self.acts
Ejemplo n.º 4
0
 def visActProbs(self, reconstructLabels):
     #since we always have labels clamped, we have no need for a negLabels variable
     cm.dot( self.W, self.hActs, target = self.negVis)
     self.negVis.add_col_vec(self.visBias)
     self.negVis.apply_sigmoid()
     if reconstructLabels:
         cm.dot( self.U, self.hActs, target = self.negLabels)
         self.negLabels.add_col_vec(self.labBias)
         #singleSoftmax(self.negLabels, self.tempLabelCol, self.tempRow)
         singleSoftmax(self.negLabels, self.tempRow)
Ejemplo n.º 5
0
 def visActProbs(self, reconstructLabels):
     #since we always have labels clamped, we have no need for a negLabels variable
     cm.dot(self.W, self.hActs, target=self.negVis)
     self.negVis.add_col_vec(self.visBias)
     self.negVis.apply_sigmoid()
     if reconstructLabels:
         cm.dot(self.U, self.hActs, target=self.negLabels)
         self.negLabels.add_col_vec(self.labBias)
         #singleSoftmax(self.negLabels, self.tempLabelCol, self.tempRow)
         singleSoftmax(self.negLabels, self.tempRow)
Ejemplo n.º 6
0
 def visActProbs(self):
     GaussianRBM.visActProbs(self) #now self.negVis holds the net input to the visible units
     #self.negVis has shape (self.numVis, self.mbsz)
     self.negVis.reshape((self.k, self.mbsz*self.numVis/self.k))
     singleSoftmax(self.negVis, self.tempRow)
     self.negVis.reshape((self.numVis, self.mbsz))