def build_toy_dataset(N, noise_std=0.1): x = np.concatenate([np.linspace(0, 2, num=N / 2), np.linspace(6, 8, num=N / 2)]) y = 0.075 * x + norm.rvs(0, noise_std, size=N) x = (x - 4.0) / 4.0 x = x.reshape((N, 1)) return x, y
def build_toy_dataset(N, noise_std=0.5): X = np.concatenate( [np.linspace(0, 2, num=N / 2), np.linspace(6, 8, num=N / 2)]) y = 2.0 * X + 10 * norm.rvs(0, noise_std, size=N) X = X.reshape((N, 1)) return X.astype(np.float32), y.astype(np.float32)
def build_toy_dataset(N=40, noise_std=0.1): ed.set_seed(0) D = 1 x = np.concatenate([np.linspace(0, 2, num=N / 2), np.linspace(6, 8, num=N / 2)]) y = np.cos(x) + norm.rvs(0, noise_std, size=N) x = (x - 4.0) / 4.0 x = x.reshape((N, D)) return {"x": x, "y": y}
def build_toy_dataset(N=40, noise_std=0.1): ed.set_seed(0) x = np.concatenate([np.linspace(0, 2, num=N/2), np.linspace(6, 8, num=N/2)]) y = 0.075*x + norm.rvs(0, noise_std, size=N) x = (x - 4.0) / 4.0 x = x.reshape((N, 1)) return {'x': x, 'y': y}
def sample_noise(self, size): """ eps = sample_noise() ~ s(eps) s.t. z = reparam(eps; lambda) ~ q(z | lambda) """ # Not using this, since TensorFlow has a large overhead # whenever calling sess.run(). #samples = sess.run(tf.random_normal(self.samples.get_shape())) return norm.rvs(size=(size, self.num_vars))
def build_toy_dataset(N=40, noise_std=0.1): D = 1 x = np.concatenate( [np.linspace(0, 2, num=N / 2), np.linspace(6, 8, num=N / 2)]) y = np.cos(x) + norm.rvs(0, noise_std, size=N) x = (x - 4.0) / 4.0 x = x.reshape((N, D)) return {'x': x, 'y': y}
def build_toy_dataset(N, noise_std=0.1): D = 1 x = np.linspace(-3, 3, num=N) y = np.tanh(x) + norm.rvs(0, noise_std, size=N) y[y < 0.5] = 0 y[y >= 0.5] = 1 x = (x - 4.0) / 4.0 x = x.reshape((N, D)) return x, y
def sample_noise(self, size): """ eps = sample_noise() ~ s(eps) s.t. z = reparam(eps; lambda) ~ q(z | lambda) """ # Not using this, since TensorFlow has a large overhead # whenever calling sess.run(). #samples = sess.run(tf.random_normal(self.samples.get_shape())) return norm.rvs(size=size)
def build_toy_dataset(n_data=40, coeff=np.random.randn(10), noise_std=0.1): n_dim = len(coeff) x = np.random.randn(n_data, n_dim) y = np.dot(x, coeff) + norm.rvs(0, noise_std, size=n_data).reshape((n_data,)) y = y.reshape((n_data, 1)) data = np.concatenate((y, x), axis=1) data = tf.constant(data, dtype=tf.float32) return ed.Data(data)
def build_toy_dataset(n_data=40, noise_std=0.1): ed.set_seed(0) D = 1 x = np.concatenate([np.linspace(0, 2, num=n_data/2), np.linspace(6, 8, num=n_data/2)]) y = np.cos(x) + norm.rvs(0, noise_std, size=n_data) x = (x - 4.0) / 4.0 x = x.reshape((n_data, D)) return {'x': x, 'y': y}
def build_toy_dataset(N=40, noise_std=0.1): ed.set_seed(0) D = 1 x = np.linspace(-3, 3, num=N) y = np.tanh(x) + norm.rvs(0, noise_std, size=N) y[y < 0.5] = 0 y[y >= 0.5] = 1 x = (x - 4.0) / 4.0 x = x.reshape((N, D)) return {'x': x, 'y': y}
def build_toy_dataset(n_data=40, noise_std=0.1): ed.set_seed(0) D = 1 x = np.linspace(-3, 3, num=n_data) y = np.tanh(x) + norm.rvs(0, noise_std, size=n_data) y[y < 0.5] = 0 y[y >= 0.5] = 1 x = (x - 4.0) / 4.0 x = x.reshape((n_data, D)) return {'x': x, 'y': y}
def build_toy_dataset(n_data=40, noise_std=0.1): ed.set_seed(0) x = np.concatenate([np.linspace(0, 2, num=n_data/2), np.linspace(6, 8, num=n_data/2)]) y = 0.075*x + norm.rvs(0, noise_std, size=n_data) x = (x - 4.0) / 4.0 x = x.reshape((n_data, 1)) y = y.reshape((n_data, 1)) data = np.concatenate((y, x), axis=1) # n_data x 2 data = tf.constant(data, dtype=tf.float32) return ed.Data(data)
def build_toy_dataset(n_data=40, noise_std=0.1): ed.set_seed(0) x = np.concatenate( [np.linspace(0, 2, num=n_data / 2), np.linspace(6, 8, num=n_data / 2)]) y = 0.075 * x + norm.rvs(0, noise_std, size=n_data) x = (x - 4.0) / 4.0 x = x.reshape((n_data, 1)) y = y.reshape((n_data, 1)) data = np.concatenate((y, x), axis=1) # n_data x 2 data = tf.constant(data, dtype=tf.float32) return ed.Data(data)
def build_toy_dataset(coeff, n_data=40, n_data_test=20, noise_std=0.1): ed.set_seed(0) n_dim = len(coeff) x = np.random.randn(n_data+n_data_test, n_dim) y = np.dot(x, coeff) + norm.rvs(0, noise_std, size=(n_data+n_data_test)) y = y.reshape((n_data+n_data_test, 1)) data = np.concatenate((y[:n_data,:], x[:n_data,:]), axis=1) data = tf.constant(data, dtype=tf.float32) data_test = np.concatenate((y[n_data:,:], x[n_data:,:]), axis=1) data_test = tf.constant(data_test, dtype=tf.float32) return ed.Data(data), ed.Data(data_test)
def build_toy_dataset(n_data=40, noise_std=0.1): ed.set_seed(0) D = 1 x = np.linspace(-3, 3, num=n_data) y = np.tanh(x) + norm.rvs(0, noise_std, size=n_data) y[y < 0.5] = 0 y[y >= 0.5] = 1 x = (x - 4.0) / 4.0 x = x.reshape((n_data, D)) y = y.reshape((n_data, 1)) data = np.concatenate((y, x), axis=1) # n_data x (D+1) data = tf.constant(data, dtype=tf.float32) return ed.Data(data)
def build_toy_dataset(coeff, n_data=40, n_data_test=20, noise_std=0.1): ed.set_seed(0) n_dim = len(coeff) x = np.random.randn(n_data + n_data_test, n_dim) y = np.dot(x, coeff) + norm.rvs(0, noise_std, size=(n_data + n_data_test)) y = y.reshape((n_data + n_data_test, 1)) data = np.concatenate((y[:n_data, :], x[:n_data, :]), axis=1) data = tf.constant(data, dtype=tf.float32) data_test = np.concatenate((y[n_data:, :], x[n_data:, :]), axis=1) data_test = tf.constant(data_test, dtype=tf.float32) return ed.Data(data), ed.Data(data_test)
def _test(loc, scale, size): val_est = norm.rvs(loc, scale, size=size).shape val_true = (size, ) + np.asarray(loc).shape assert val_est == val_true
def build_toy_dataset(N, coeff=np.random.randn(10), noise_std=0.1): n_dim = len(coeff) x = np.random.randn(N, n_dim).astype(np.float32) y = np.dot(x, coeff) + norm.rvs(0, noise_std, size=N) return x, y
def _test(self, loc, scale, size): val_est = norm.rvs(loc, scale, size=size).shape val_true = (size, ) + np.asarray(loc).shape assert val_est == val_true
def build_toy_dataset(N=50, noise_std=0.1): x = np.linspace(-3, 3, num=N) y = np.cos(x) + norm.rvs(0, noise_std, size=N) x = x.reshape((N, 1)) return {'x': x, 'y': y}
def build_toy_dataset(N=50, noise_std=0.1): x = np.linspace(-3, 3, num=N) y = np.cos(x) + norm.rvs(0, noise_std, size=N) x = x.reshape((N, 1)) return x, y
def build_toy_dataset(n_data=40, coeff=np.random.randn(10), noise_std=0.1): n_dim = len(coeff) x = np.random.randn(n_data, n_dim).astype(np.float32) y = np.dot(x, coeff) + norm.rvs(0, noise_std, size=n_data) return {'x': x, 'y': y}