The documentation for tf.layers.conv2d says: "useBias (boolean) Whether the layer uses a bias vector. Defaults to false. Optional".
But testing with code says otherwise:
m = tf.sequential();
m.add(tf.layers.conv2d({inputShape:[28,28,1], filters:16, kernelSize:4}));
console.log(m.layers[0].weights);
Prints a list with two elements. Adding useBias:false and it prints a list with one element.
The documentation also says "filters (number) The dimensionality of the output space (i.e. the number of filters in the convolution). Optional" but as far as I can tell, the number of filters is not optional:
m = tf.sequential();
m.add(tf.layers.conv2d({inputShape:[28,28,1], kernelSize:4}));
Prints:
[email protected]:1 Uncaught Error: Constructing tensor of shape (NaN) should match the length of values (0)
at Object.a [as assert] ([email protected]:1)
at new e ([email protected]:1)
at Function.e.make ([email protected]:1)
at e.toTensor ([email protected]:1)
at e.truncatedNormal ([email protected]:1)
at [email protected]:1
at Object.e.tidy ([email protected]:1)
at Object.n.value [as truncatedNormal] ([email protected]:1)
at Object.C [as truncatedNormal] ([email protected]:1)
at t.apply ([email protected]:1)
Thanks Kyle. Cc @caisq @bileschi @ericdnielsen for tf.layers
So , file /src/layers/convolutional.ts line 119
"this.useBias = config.useBias == null ? true : config.useBias;" should be changed to "this.useBias = config.useBias == null ? false : config.useBias;"?????
or if (config.useBias != null) {
this.useBias = config.useBias;
}?????
@kylemcdonald Thanks for reporting these issues.
@MengShaoying This is a documentation bug. useBias should default to true (like in Python Keras).
filters is not optional. I'll send a PR to fix these soon.