示例#1
0
文件: model.py 项目: mklf/Lican
    def _validateModel(self):
        if self.criterion.type=='ClassNLLCriterion':
            last_layer = self.net[-1]
            while isinstance(last_layer, Container):
                last_layer = last_layer[-1]

            if last_layer.type != 'SoftMax':
                log_model.info('add SoftMax layer to last layer for '
                                          'using ClassNLLCriterion')
                self.net.add(SoftMax())
示例#2
0
文件: container.py 项目: mklf/Lican
    def forward(self,input):
        if isinstance(input,np.ndarray):
            x = Def_TensorTypes[len(input.shape)-1]
            if not self._forward:
                log_model.info('compile the network')
                self._forward = function(inputs=[x],outputs=self.get_output(x),
                                         allow_input_downcast=True)
                return self._forward(input)
            else:
                return self._forward(input)

        return self.get_output(input)