예제 #1
0
 def call(self, inputs):
     x = relu(self.linear1(inputs))
     x = relu(self.linear2(x))
     x = relu(self.linear3(x))
     x = self.linear4(x)
     z_mean = x[:, :self.latent_dim]
     z_log_var = softplus(x[:, self.latent_dim:])
     return z_mean, z_log_var
  def test_softplus(self):
    def softplus(x):
      return np.log(np.ones_like(x) + np.exp(x))

    x = backend.placeholder(ndim=2)
    f = backend.function([x], [activations.softplus(x)])
    test_values = np.random.random((2, 5))
    result = f([test_values])[0]
    expected = softplus(test_values)
    self.assertAllClose(result, expected, rtol=1e-05)
예제 #3
0
 def call(self, inputs, **kwargs):
     mu = self.dense_mu(inputs)
     pre_sigma = self.dense_pre_sigma(inputs)
     sigma = softplus(pre_sigma)
     return mu, sigma