Softmax3D.compute_tensor()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from layer import NeuralLayer
5
import theano
6
import theano.tensor as T
7
8
class Softmax3D(NeuralLayer):
9
10
    def __init__(self):
11
        super(Softmax3D, self).__init__("softmax")
12
13
    def compute_tensor(self, x):
14
        shape = x.shape
15
        x = x.reshape((-1, shape[-1]))
16
        softmax_tensor = T.nnet.softmax(x)
17
18
        return softmax_tensor.reshape(shape)