* Centers the input and applies the following function to every element of * the input. * * x => [max(x, 0), max(-x, 0)] * * The theory being that there may be signal in the both negative and positive * portions of the input. Note that this will double the number of channels.
(inputs, kwargs)
| 63 | * example code. |
| 64 | */ |
| 65 | call(inputs, kwargs) { |
| 66 | let input = inputs; |
| 67 | if (Array.isArray(input)) { |
| 68 | input = input[0]; |
| 69 | } |
| 70 | this.invokeCallHook(inputs, kwargs); |
| 71 | const origShape = input.shape; |
| 72 | const flatShape = |
| 73 | [origShape[0], origShape[1] * origShape[2] * origShape[3]]; |
| 74 | const flattened = input.reshape(flatShape); |
| 75 | const centered = tf.sub(flattened, flattened.mean(1).expandDims(1)); |
| 76 | const pos = centered.relu().reshape(origShape); |
| 77 | const neg = centered.neg().relu().reshape(origShape); |
| 78 | return tf.concat([pos, neg], 3); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * If a custom layer class is to support serialization, it must implement |
nothing calls this directly
no outgoing calls
no test coverage detected