def test_pooled():
    channel = 1
    data = get_example_dataset(10)
    for img_data in data:
        img = img_data[channel]
        sum_ = img.sum()
        plot_pooled(img, 10)
        assert img.sum() == sum_
def manual_plot_fake_data_test():
    shape = [1, 100, 30]
    count_examples = 5
    data = torch.rand([count_examples] + shape)

    for i in range(count_examples):
        plot_pooled(data[i])
    plt.show()
pred = model(test_sample_gpu).detach().cpu()

# %%
pred[0, 0].sum()

# %%
test_sample[0, 0].max()

# %%

# %%
for test_sample in test:
    # event = event.view(1,*event.size())
    # print(event.size())
    scale = 10
    plot_data.plot_pooled(test_sample[0, 0], scale)
    test_sample_gpu = test_sample.to(device)
    pred = model(test_sample_gpu).detach().cpu()
    plot_data.plot_pooled(pred[0, 0], scale)
    plt.show()

    true_hist = preproc.scale_to_01(test_sample[0]).numpy().flatten()
    pred_hist = preproc.scale_to_01(pred[0]).numpy().flatten()
    m = plt.hist([true_hist, pred_hist], bins=10, label=["true", "pred"])
    plt.legend()
    plt.yscale("log")
    plt.show()

# %%
m
def manual_plot_MC_test():
    data = get_example_dataset(10)
    for i, event in enumerate(data):
        print(event.size())
        plot_pooled(event)
示例#5
0
ev = event[0].transpose(-1, -2)

gauss_blur = kornia.filters.GaussianBlur((9, 9), (1, 1))
ev = gauss_blur(ev.view(1, 1, *ev.size()))

ev = ev.view(ev.size()[2::])
plt.figure(figsize=(20, 4))
plt.imshow(ev, norm=LogNorm())
plt.colorbar()

#%%
event_ = event.view(1, *event.size())  # fake batch dimension
pred = model(event_.to(device)).detach().cpu()[0]
gauss_blur = kornia.filters.GaussianBlur((21, 21), (1, 1))
ev = gauss_blur(event_)

plot_pooled(ev[0][0], 5)
plt.title("blurred MC truth used for loss")

plot_pooled(clip_scale(event_, False)[0][0], 5, True)
plt.title("MC truth")

plot_pooled(clip_scale(F.sigmoid(pred[0]), True), 5, True)
plt.title("prediction")

#%%
# model_name = "???"
# torch.save(model.state_dict(),"../models/%s-dict.pt"%model_name)
# torch.save(model,"../models/%s.pt"%model_name)