From 7fe3782e65991a592fb6cb612202b3983a274e88 Mon Sep 17 00:00:00 2001 From: delzac Date: Sun, 10 Mar 2019 17:44:24 +0800 Subject: [PATCH] allow init in dense to be directly initialised by numpy array --- bindings/python/cntk/layers/layers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bindings/python/cntk/layers/layers.py b/bindings/python/cntk/layers/layers.py index 06cf3e330c9c..f5995243ba29 100644 --- a/bindings/python/cntk/layers/layers.py +++ b/bindings/python/cntk/layers/layers.py @@ -135,7 +135,11 @@ def Dense(shape, activation=default_override_or(identity), init=default_override infer_input_rank_to_map = map_rank # infer W to use all input dims except the first static 'map_rank' ones # parameters bound to this Function - init_weights = _initializer_for(init, Record(output_rank=output_rank)) + if isinstance(init, np.ndarray): + init_weights = init + else: + init_weights = _initializer_for(init, Record(output_rank=output_rank)) + W = Parameter(input_shape + output_shape, init=init_weights, name='W') b = Parameter( output_shape, init=init_bias, name='b') if bias else None