Why does obtaining a new initialization function with partial
give me an error, while a lambda
doesn't?
All of these functions:
f_init = partial(tf.random_normal, mean=0.0, stddev=0.01, partition_info=None)
f_init = partial(tf.contrib.layers.xavier_initializer, partition_info=None)
f_init = partial(tf.random_normal, mean=0.0, stddev=0.01)
f_init = tf.contrib.layers.xavier_initializer
Throw the following exception:
TypeError: ... got an unexpected keyword argument 'partition_info'
(while ...
stands for xavier_initializer
and the other functions, of course)
When applied to a simple conv2d
layer:
conv1 = tf.layers.conv2d(x, 32, [5, 5],
strides=[1, 1],
padding="same",
activation=tf.nn.relu,
kernel_initializer=f_init,
name="conv1")
However, if I use a lambda
to obtain custom initialization functions:
f_init = lambda shape, dtype, partition_info=None:\
tf.random_normal(shape, mean=0.0, stddev=0.01, dtype=dtype)
...it works without any problems.
Shouldn't partial
also return a new anonymous function of, e.g., tf.random_normal
supplied with mean=0.0
and stddev=0.01
like the lambda statement does?