import tile from 'ndarray-tile'
...
_call_cpu(x) {
this.output = x
let alpha_tiled;
let tileAlphas = false;
let tiling = [];
for (let i = 0;i < x.tensor.shape.length;i++) {
if (x.tensor.shape[i] != this.weights['alpha'].tensor.shape[i]) {
tileAlphas = true;
tiling.push(x.tensor.shape[i]);
} else {
tiling.push(1);
}
}
if (tileAlphas) {
alpha_tiled = tile(this.weights['alpha'].tensor, tiling);
} else {
alpha_tiled = this.weights['alpha'].tensor;
}
this._compute(this.output.tensor, alpha_tiled);
}
For _call_gpu I actually didn't need to change anything, as these work fine with the "shared axis"-dimensions set to one pixel (effectively sharing weights across that dimension).
I could try to do something slightly more general than this and submit a PR if you're interested. I noticed there seemed to be a lot of changes in the code recently, though, so wasn't sure whether there were already plans underway to modify the existing code or fix this at a later stage.
Hi,
it seems the option
shared_axes
for PReLU activations (https://keras.io/layers/advanced-activations/#prelu) is not supported in Keras-js. In my case I made a simple hack around this by modifying the code here:For
_call_gpu
I actually didn't need to change anything, as these work fine with the "shared axis"-dimensions set to one pixel (effectively sharing weights across that dimension).I could try to do something slightly more general than this and submit a PR if you're interested. I noticed there seemed to be a lot of changes in the code recently, though, so wasn't sure whether there were already plans underway to modify the existing code or fix this at a later stage.