-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
type:bugSomething isn't workingSomething isn't working
Description
This affects initializers like 'glorotUniform' and 'glorotNormal'.
I think computeFans
(see https://github.com/tensorflow/tfjs/blob/master/tfjs-layers/src/initializers.ts ) is incorrect:
- fan_in should be:
kernelHeight × kernelWidth
Reproducible Example:
const input = tf.randomNormal([1, 64, 64, 64]);
const dw = tf.layers.depthwiseConv2d({
kernelSize: 3,
useBias: false,
depthwiseInitializer: 'leCunUniform'
});
const output = dw.apply(input);
console.log(`Output mean=${tf.moments(output).mean.arraySync().toFixed(3)}, variance=${tf.moments(output).variance.arraySync().toFixed(3)}`);
// Output mean=-0.000, variance=0.016
Corrected Behavior Example:
const input = tf.randomNormal([1, 64, 64, 64]);
const dw = tf.layers.depthwiseConv2d({
kernelSize: 3,
useBias: false,
depthwiseInitializer: tf.initializers.randomUniform({minval: -Math.sqrt(3 / (3**2)), maxval: Math.sqrt(3 / (3**2))})
});
const output = dw.apply(input);
console.log(`Output mean=${tf.moments(output).mean.arraySync().toFixed(3)}, variance=${tf.moments(output).variance.arraySync().toFixed(3)}`);
// Output mean=-0.004, variance=0.964
Metadata
Metadata
Assignees
Labels
type:bugSomething isn't workingSomething isn't working