How does one apply max(0,z) element-wise in a vectorized way (apply ReLu linear rectifier element-wise)
26 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I wanted to implement something similar to applying a mathematical function element-wise to a matrix. For example something like:
kernel_matrix = max(0, W' * X + b) %linear rectifier element-wise vectorized code
in a manner that the code is vectorized. Is this possible in matlab? So far the max documentation doesn't seem super helpful.
Ideally, it would be important that this element-wise way of doing this is supported by GPU arrays too.
So for example if our matrix we want to pass through the ReLu is:
>> A
A =
8 1 6
3 5 7
4 9 2
and the following is the threshold the neurons/ReLu should activate:
B =
1 7 9
3 1 1
8 4 4
then the ReLu should only activate when A(i,j) - B(i,j) >= 0 to produce:
activation =
8 0 0
3 5 7
0 9 0
2 Kommentare
Roger Stafford
am 25 Mär. 2016
It isn't clear what matrix the term "element-wise" is to apply to. Please give information about the sizes of the various variables here and what "element-wise" is to apply to.
Antworten (2)
Joss Knight
am 29 Mär. 2016
Not quite sure whether your point is clear because this is exactly how the two-argument form of max works - element-wise.
>> max(0, magic(3)-5)
ans =
3 0 1
0 0 2
0 4 0
0 Kommentare
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!