def _get_initializer(initializer): if initializer is None: return LeCunNormal() if numpy.isscalar(initializer): return Constant(initializer) if isinstance(initializer, numpy.ndarray): return Constant(initializer) if not callable(initializer): raise TypeError('invalid type of initializer: %s' % type(initializer)) return initializer
def _get_initializer(initializer): # type: (tp.Optional[types.InitializerSpec]) -> types.AbstractInitializer # NOQA if initializer is None: return LeCunNormal() if (isinstance(initializer, chainer.get_array_types()) or numpy.isscalar(initializer)): return Constant(initializer) if not callable(initializer): raise TypeError('invalid type of initializer: %s' % type(initializer)) return initializer