Created
August 10, 2015 12:51
-
-
Save fmder/5e54ec914fcff6e5622e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import product | |
import theano.tensor as T | |
from theano import config | |
from pylearn2.models.mlp import Softmax | |
class ConfusionSoftmax(Softmax): | |
def get_layer_monitoring_channels(self, state_below=None, | |
state=None, targets=None): | |
rval = super(ConfusionSoftmax, self).get_layer_monitoring_channels(state_below, state, targets) | |
if (state_below is not None) or (state is not None): | |
if state is None: | |
state = self.fprop(state_below) | |
if (targets is not None): | |
if ((not self._has_binary_target) or | |
self.binary_target_dim == 1): | |
y = T.argmax(targets, axis=1) | |
for j in range(10): | |
rval["y[%i]" % (j)] = T.cast(y[j], config.floatX) | |
return rval |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment