python - initialize matrices in tensorflow -


i have 6 matrices, model learn, defined them follow:

self.r= tf.get_variable('r_',dtype=tf.float32, shape=[6,300 ,300],            initializer=tf.random_uniform_initializer(maxval=0.1, minval=-0.1)) 

what need change initialization. want initialize each 1 of them identity matrix. can me that?

if want create 6x300x300 matrix each 300x300 array identity matrix can simply:

import numpy np;  dimension = 300  singleidentitymatrix = np.identity(dimension, dtype= np.float32)  stackedmatrix = np.dstack( [singleidentitymatrix] * 6) 

and pass matrix

self.r = tf.variable(initial_value = stackedmatrix) 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -