DimShuffle   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 6 3
A compute_tensor() 0 2 1
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from . import NeuralLayer
5
6
class DimShuffle(NeuralLayer):
7
    """
8
    DimShuffle layer.
9
    """
10
11
    def __init__(self, *pattern):
12
        super(DimShuffle, self).__init__("dimshuffle")
13
        if len(pattern) == 1 and type(pattern[0]) == list:
14
            self.pattern = pattern[0]
15
        else:
16
            self.pattern = pattern
17
18
    def compute_tensor(self, x):
19
        return x.dimshuffle(*self.pattern)