MCPcopy Create free account
hub / github.com/Zhangyanbo/diffusion-evolution / compare_latent_plot

Function compare_latent_plot

experiments/RL/visualization.py:127–144  ·  view source on GitHub ↗
(pop, pop_raw, pop_cmaes, random_map, pop_large, random_map_large, ax=None)

Source from the content-addressed store, hash-verified

125 ax.scatter(z[:, 0], z[:, 1], zorder=zorder, marker='o', color=color, alpha=alpha, label=label, edgecolors='none')
126
127def compare_latent_plot(pop, pop_raw, pop_cmaes, random_map, pop_large, random_map_large, ax=None):
128 if ax is None:
129 ax = plt.gca()
130 latent_plot(random_map(pop).detach(), ax, color='#E93A01', label='latent diffusion evolution', alpha=0.5)
131 latent_plot(random_map(pop_raw).detach(), ax, color='#46B3D5', label='DiffEvo', alpha=0.25)
132 latent_plot(random_map(pop_cmaes).detach(), ax, color='#6F6E6E', alpha=0.5, label='CMA-ES')
133 latent_plot(random_map_large(pop_large).detach(), ax, color='#F5851E', alpha=0.25, label='latent DiffEvo (high-d)')
134
135 # calculate the range of the data
136 x = torch.cat([random_map(pop).detach(), random_map(pop_raw).detach(), random_map_large(pop_large).detach()], dim=0) # not include cmaes
137 x_mean = x.mean(dim=0)
138 x_std = x.std(dim=0)
139 n = 3.0
140
141 ax.set_xlabel('$z_1$')
142 ax.set_ylabel('$z_2$')
143 ax.set_xlim(x_mean[0]-n*x_std[0], x_mean[0]+n*x_std[0])
144 ax.set_ylim(x_mean[1]-n*x_std[1], x_mean[1]+n*x_std[1])
145
146def draw_cartpole_demo(ax):
147 ax.axhline(y=0, color='gray', linestyle='--')

Callers 1

visualization.pyFile · 0.85

Calls 1

latent_plotFunction · 0.85

Tested by

no test coverage detected