Return a float representing the number of errors in the minibatch over the total number of examples of the minibatch :type y: theano.tensor.TensorType :param y: corresponds to a vector that gives for each example the correct label
(self, y)
| 119 | return -T.mean(T.log(self.p_y_given_x)[T.arange(y.shape[0]), y]) |
| 120 | |
| 121 | def errors(self, y): |
| 122 | """Return a float representing the number of errors in the minibatch |
| 123 | over the total number of examples of the minibatch |
| 124 | |
| 125 | :type y: theano.tensor.TensorType |
| 126 | :param y: corresponds to a vector that gives for each example |
| 127 | the correct label |
| 128 | """ |
| 129 | |
| 130 | # check if y has same dimension of y_pred |
| 131 | if y.ndim != self.y_pred.ndim: |
| 132 | raise TypeError( |
| 133 | 'y should have the same shape as self.y_pred', |
| 134 | ('y', y.type, 'y_pred', self.y_pred.type) |
| 135 | ) |
| 136 | # check if y is of the correct datatype |
| 137 | if y.dtype.startswith('int'): |
| 138 | # the T.neq operator returns a vector of 0s and 1s, where 1 |
| 139 | # represents a mistake in prediction |
| 140 | return T.mean(T.neq(self.y_pred, y)) |
| 141 | else: |
| 142 | raise NotImplementedError() |
| 143 | |
| 144 | |
| 145 | def cg_optimization_mnist(n_epochs=50, mnist_pkl_gz='mnist.pkl.gz'): |
no outgoing calls