Skip to content

Instantly share code, notes, and snippets.

@nanguoyu
Last active December 12, 2022 10:24
Show Gist options
  • Save nanguoyu/248516e7c74b2cd9ac8e6b56cfb9c540 to your computer and use it in GitHub Desktop.
Save nanguoyu/248516e7c74b2cd9ac8e6b56cfb9c540 to your computer and use it in GitHub Desktop.
3D Beta space
hyper_output = []
with tqdm(range(-180, 181, 10), position=0) as t:
for x in t:
for y in tqdm(range(-180, 181, 10), disable=True):
for z in tqdm(range(-180, 181, 10), disable=True):
angles = torch.tensor([x,y,z])/180*torch.pi
Hyper_x = transform_angles(angles=angles).to(device=gpu_computation)
hyper_output.append(model.hyper_stack(Hyper_x).cpu().detach().numpy())
# Update the description of progressbar
t.set_postfix(Angles = [x,y,z])
print("Done!")
hyper_output = np.stack(hyper_output)
print(hyper_output.shape)
Beta = hyper_output
beta_selected = []
Beta_d0_to_d2_mean = Beta[:, 0:3].mean(axis=0)
Beta_d0_to_d2_var = Beta[:, 0:3].var(axis=0)
print(f'mean: {Beta_d0_to_d2_mean} var: {Beta_d0_to_d2_var}')
for i, beta in enumerate(Beta):
if np.linalg.norm(beta[0:3]-Beta_d0_to_d2_mean)<=0.08:
beta_selected.append(beta)
beta_selected = np.array(beta_selected)
fig = go.Figure(data=[go.Scatter3d(x=beta_selected[:,3], y=beta_selected[:,4], z=beta_selected[:,5],
mode='markers', marker_size=1)])
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment