Keras initializers outside keras

I want to initialize a 4 * 11 matrix using the smoothing uniform in keras using the following code:

import keras keras.initializers.glorot_uniform((4,11)) 

and getting output:

 <keras.initializers.VarianceScaling at 0x7f9666fc48d0> 

how to visualize the output. I try c [1] and get the output of 'VarianceScaling' object does not support indexing

+5
source share
1 answer

glorot_uniform() creates a function, and later this function will be called using the form. Therefore you need to:

 from keras.initializers import * unif = glorot_uniform() #this returns a 'function(shape)' mat_as_tensor = unif((4,11)) #this returns a tensor - use this in keras models if needed mat_as_numpy = K.eval(mat) #this returns a numpy array (don't use in models) print(mat_as_numpy) 
+4
source

Source: https://habr.com/ru/post/1272659/


All Articles