Is it possible to do updates of the guide with new data without using the previous data?
Using the code from the Bayesian Regression Example:
N = 100 # size of toy data
def build_linear_dataset(N, w=3, p=1, noise_std=0.01):
X = np.random.rand(N, p)
# w = 3
w = w * np.ones(p)
# b = 1
y = np.matmul(X, w) + np.repeat(1, N) + np.random.normal(0, noise_std, size=N)
y = y.reshape(N, 1)
X, y = torch.tensor(X).type(torch.Tensor), torch.tensor(y).type(torch.Tensor)
data = torch.cat((X, y), 1)
assert data.shape == (N, p + 1)
return data
data = build_linear_dataset(N, w=3)
pyro.clear_param_store()
for j in range(num_iterations):
# calculate the loss and take a gradient step
loss = svi.step(data)
if j % 100 == 0:
print("[iteration %04d] loss: %.4f" % (j + 1, loss / float(N)))
for name in pyro.get_param_store().get_all_param_names():
print("[%s]: %.3f" % (name, pyro.param(name).data.numpy()))
data = build_linear_dataset(N, w=1)
for j in range(num_iterations):
# calculate the loss and take a gradient step
loss = svi.step(data)
if j % 100 == 0:
print("[iteration %04d] loss: %.4f" % (j + 1, loss / float(N)))
for name in pyro.get_param_store().get_all_param_names():
print("[%s]: %.3f" % (name, pyro.param(name).data.numpy()))
Output:
[guide_mean_weight]: 2.994
[guide_log_scale_weight]: -3.848
[guide_mean_bias]: 0.994
[guide_log_scale_bias]: -4.169
[guide_mean_weight]: 1.000
[guide_log_scale_weight]: -4.037
[guide_mean_bias]: 0.998
[guide_log_scale_bias]: -4.521
I would like to “continue” training s.t. the final weight is 2 (so the mean between 3 and 1) and not 1.
Thanks a lot for any hints.