forked from CharlieFL/JDF-Python2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlayers.py
More file actions
22 lines (16 loc) · 646 Bytes
/
Copy pathlayers.py
File metadata and controls
22 lines (16 loc) · 646 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import lasagne as nn
from lasagne import nonlinearities
try:
from theano.sandbox.cuda import dnn
from lasagne.layers.dnn import DNNLayer, conv_output_length
except ImportError:
print "No cudnn, not imported."
DNNLayer = nn.layers.Layer
class ApplyNonlinearity(nn.layers.Layer):
def __init__(self, input_layer, nonlinearity=nonlinearities.softmax):
super(ApplyNonlinearity, self).__init__(input_layer)
self.nonlinearity = nonlinearity
def get_output_shape_for(self, input_shape):
return input_shape
def get_output_for(self, input, *args, **kwargs):
return self.nonlinearity(input)