def convnet(inputs, cond, filters, hps, channels): inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1")) inputs = tf.nn.relu( conv2d(inputs, filters, filter_size=[1, 1], name="conv2d_2")) # 前两个卷积层通道数为c,使用ReLU激活函数,卷积核大小分别为3*3 和 1*1 inputs = conv2d_zeros(inputs, channels, name="conv2d_3") return inputs
def split2d_prior(z, hps): n_z2 = int(z.get_shape()[3]) n_z1 = n_z2 h = conv2d_zeros(z, 2 * n_z1, name="conv") mean, logsd = tf.split(h, 2, axis=-1) rescale = tf.get_variable("rescale", [], initializer=tf.constant_initializer(1.)) scale_shift = tf.get_variable("scale_shift", [], initializer=tf.constant_initializer(0.)) logsd = tf.tanh(logsd) * rescale + scale_shift return gaussian_diag(mean, logsd)
def prior(y_onehot, hps, name=None): n_z = hps.top_shape[-1] h = tf.zeros([tf.shape(y_onehot)[0]]+hps.top_shape[:2]+[2*n_z]) h = conv2d_zeros(h, 2*n_z, name="p") if hps.ycond: h += tf.reshape(linear_zeros(y_onehot, 2*n_z, name="y_emb"), [-1, 1, 1, 2 * n_z]) mean, logsd = tf.split(h, 2, axis=-1) rescale = tf.get_variable("rescale", [], initializer=tf.constant_initializer(1.)) scale_shift = tf.get_variable("scale_shift", [], initializer=tf.constant_initializer(0.)) logsd = tf.tanh(logsd) * rescale + scale_shift pz = gaussian_diag(mean, logsd) logp = lambda z1: pz.logp(z1) eps = lambda z1: pz.get_eps(z1) sample = lambda eps: pz.sample(eps) return logp, sample, eps
def prior(y_onehot, hps, name=None): n_z = hps.top_shape[-1] h = tf.zeros([tf.shape(y_onehot)[0]] + hps.top_shape[:2] + [2 * n_z]) h = conv2d_zeros(h, 2 * n_z, name="p") if hps.ycond: h += tf.reshape(linear_zeros(y_onehot, 2 * n_z, name="y_emb"), [-1, 1, 1, 2 * n_z]) mean, logsd = tf.split(h, 2, axis=-1) rescale = tf.get_variable("rescale", [], initializer=tf.constant_initializer(1.)) scale_shift = tf.get_variable("scale_shift", [], initializer=tf.constant_initializer(0.)) logsd = tf.tanh(logsd) * rescale + scale_shift pz = gaussian_diag(mean, logsd) logp = lambda z1: pz.logp(z1) eps = lambda z1: pz.get_eps(z1) sample = lambda eps: pz.sample(eps) return logp, sample, eps
def convnet(inputs, cond, filters, hps, channels): inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1")) inputs = tf.nn.relu( conv2d(inputs, filters, filter_size=[1, 1], name="conv2d_2")) inputs = conv2d_zeros(inputs, channels, name="conv2d_3") return inputs
def convnet(inputs, cond, filters, hps, channels): inputs = tf.nn.relu(conv2d(inputs, width=filters, name="conv2d_1")) inputs = tf.nn.relu(conv2d(inputs, filters, filter_size=[1,1], name="conv2d_2")) inputs = conv2d_zeros(inputs, channels, name="conv2d_3") return inputs