-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectify.m
39 lines (29 loc) · 1.08 KB
/
Rectify.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
classdef Rectify < SingleParentNode
methods
function obj = Rectify(parent, varargin)
obj = obj@SingleParentNode(parent, varargin{:});
end
end
methods (Access = protected)
function value = evalElement(obj)
value = max(obj.parents.evalImpl(), 0);
end
function computeScaleElement(obj)
obj.scale = max(obj.parents.scale, 0);
end
function height = getCompiledHeight(~)
height = 1;
end
function [headObj, tailObj] = replaceNonlinearElement(obj)
a = max(abs(obj.parents.scale));
tailObj = [
Linear(obj.parents, [-0.17411 3.9827/a]) ...
Linear(obj.parents, [-1.5403 2.0606/a]) ...
Linear(obj.parents, [-0.083809 4.0249/a])];
h1 = Tanh(tailObj(1));
h2 = Tanh(tailObj(2));
h3 = Tanh(tailObj(3));
headObj = Linear([h1 h2 h3], [0.62512 1.5796 0.49797 -1.4523]*a);
end
end
end