比如这么一段tensorflow的代码,怎么改成 model = models.Sequential() .... model.add 的模型呢
def xavier_init(shape):
return tf.random_normal(shape = shape, stddev = 1./tf.sqrt(shape[0]/2.0))
Gen_AB_W = {"Gen_H": tf.Variable(xavier_init([image_dimension, H_dim])),
"Gen_final": tf.Variable(xavier_init([H_dim, image_dimension]))}
Gen_AB_Bias = {"Gen_H": tf.Variable(xavier_init([H_dim])),
"Gen_final": tf.Variable(xavier_init([image_dimension]))}
def Gen_AB(x):
G_hidden_layer = tf.nn.relu(tf.add(tf.matmul(x, Gen_AB_W["Gen_H"]), Gen_AB_Bias["Gen_H"]))
gen_output = tf.add(tf.matmul(G_hidden_layer, Gen_AB_W["Gen_final"]), Gen_AB_Bias["Gen_final"
gen_prob_output = tf.nn.sigmoid(gen_output)
return gen_prob_output