def compile(self, in_x, train_feed, eval_feed):
n = np.product(self.in_d)
m, param_init_fn = [dom[i] for (dom, i) in zip(self.domains, self.chosen)]
#sc = np.sqrt(6.0) / np.sqrt(m + n)
#W = tf.Variable(tf.random_uniform([n, m], -sc, sc))
W = tf.Variable( param_init_fn( [n, m] ) )
b = tf.Variable(tf.zeros([m]))
# if the number of input dimensions is larger than one, flatten the
# input and apply the affine transformation.
if len(self.in_d) > 1:
in_x_flat = tf.reshape(in_x, shape=[-1, n])
out_y = tf.add(tf.matmul(in_x_flat, W), b)
else:
out_y = tf.add(tf.matmul(in_x, W), b)
return out_y
# computes the output dimension based on the padding scheme used.
# this comes from the tensorflow documentation
评论列表
文章目录