How to represent the [variable_scope] and [get_variable] in tensorflow java ?
HI : write the tensorflow code in python ,we always use with the variable_scope and get_variable method , like this
with tf.compat.v1.variable_scope('Qifficulty'):
question_difficulty_weights = tf.compat.v1.get_variable('weights', [q.get_shape()[-1], 1],
initializer= tf.initializers.glorot_uniform(seed=0))
# layers.xavier_initializer(seeed=0))
question_difficulty_biases = tf.compat.v1.get_variable('biases', [1],
initializer=tf.compat.v1.zeros_initializer())
question_difficulty = tf.nn.tanh(tf.matmul(q, question_difficulty_weights) + question_difficulty_biases)
but in java ,we can not use with key word , and I also can not find [variable_scope] and [get_variable] two apis.
I just want to know How to represent the [variable_scope] and [get_variable] in tensorflow java ,could we give me a damo about these?
We don't have an equivalent of variable scope, though you can name the scope which has a similar effect, but if you have a graph ops instance you can call variable() and pass in an org.tensorflow.framework.initializers instance or do it by hand (e.g. https://github.com/tensorflow/java-models/blob/master/tensorflow-examples/src/main/java/org/tensorflow/model/examples/cnn/lenet/CnnMnist.java#L103).
We don't have an equivalent of variable scope, though you can name the scope which has a similar effect, but if you have a graph ops instance you can call
variable()and pass in anorg.tensorflow.framework.initializersinstance or do it by hand (e.g. https://github.com/tensorflow/java-models/blob/master/tensorflow-examples/src/main/java/org/tensorflow/model/examples/cnn/lenet/CnnMnist.java#L103).
good example project, we need more , thx