The official Tensorflow API doc claims that the parameter kernel_initializer
defaults to None
for tf.layers.conv2d
and tf.layers.dense
.
However, reading the layers tutorial (https://www.tensorflow.org/tutorials/layers), I noted that this parameter is not set in the code. For example:
# Convolutional Layer #1
conv1 = tf.layers.conv2d(
inputs=input_layer,
filters=32,
kernel_size=[5, 5],
padding="same",
activation=tf.nn.relu)
The example code from the tutorial runs without any errors, so I think the default kernel_initializer
is not None
. So, which initializer is used?
In another code, I did not set the kernel_initializer
of the conv2d and dense layers, and everything was fine. However, when I tried to set the kernel_initializer
to tf.truncated_normal_initializer(stddev=0.1, dtype=tf.float32)
, I got NaN errors. What is going on here? Can anyone help?