+ fig = plt.figure()
+ fig.set_figheight(5)
+ fig.set_figwidth(8)
+
+ ax = fig.add_subplot(1, 1, 1)
+
+ x = generate((10000, 1), T, alpha, alpha_bar, sigma,
+ model, train_mean, train_std)
+
+ ax.set_xlim(-1.25, 1.25)
+ ax.spines.right.set_visible(False)
+ ax.spines.top.set_visible(False)
+
+ d = train_input.flatten().detach().to('cpu').numpy()
+ ax.hist(d, 25, (-1, 1),
+ density = True,
+ histtype = 'bar', edgecolor = 'white', color = 'lightblue', label = 'Train')
+
+ d = x.flatten().detach().to('cpu').numpy()
+ ax.hist(d, 25, (-1, 1),
+ density = True,
+ histtype = 'step', color = 'red', label = 'Synthesis')
+
+ ax.legend(frameon = False, loc = 2)
+
+ filename = f'minidiffusion_{args.data}.pdf'
+ print(f'saving {filename}')
+ fig.savefig(filename, bbox_inches='tight')
+
+ if not args.no_window and hasattr(plt.get_current_fig_manager(), 'window'):
+ plt.get_current_fig_manager().window.setGeometry(2, 2, 1024, 768)
+ plt.show()
+
+########################################
+# Nx2 -> scatter plot
+elif train_input.dim() == 2 and train_input.size(1) == 2:
+
+ fig = plt.figure()
+ fig.set_figheight(6)
+ fig.set_figwidth(6)
+
+ ax = fig.add_subplot(1, 1, 1)
+
+ x = generate((1000, 2), T, alpha, alpha_bar, sigma,
+ model, train_mean, train_std)
+
+ ax.set_xlim(-1.5, 1.5)
+ ax.set_ylim(-1.5, 1.5)
+ ax.set(aspect = 1)
+ ax.spines.right.set_visible(False)
+ ax.spines.top.set_visible(False)
+
+ d = train_input[:x.size(0)].detach().to('cpu').numpy()
+ ax.scatter(d[:, 0], d[:, 1],
+ s = 2.5, color = 'gray', label = 'Train')
+
+ d = x.detach().to('cpu').numpy()
+ ax.scatter(d[:, 0], d[:, 1],
+ s = 2.0, color = 'red', label = 'Synthesis')
+
+ ax.legend(frameon = False, loc = 2)
+
+ filename = f'minidiffusion_{args.data}.pdf'
+ print(f'saving {filename}')
+ fig.savefig(filename, bbox_inches='tight')
+
+ if not args.no_window and hasattr(plt.get_current_fig_manager(), 'window'):
+ plt.get_current_fig_manager().window.setGeometry(2, 2, 1024, 768)
+ plt.show()
+
+########################################
+# NxCxHxW -> image
+elif train_input.dim() == 4:
+
+ x = generate((128,) + train_input.size()[1:], T, alpha, alpha_bar, sigma,
+ model, train_mean, train_std)