3D Scatter

Neural Network Embeddings (t-SNE)

3D t-SNE visualization of neural network activation embeddings showing class separation.

Output
Neural Network Embeddings (t-SNE)
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(321)

# Simulate t-SNE of neural network activations
n_samples = 300

# Create 5 class clusters in 3D embedding space
classes = 5
colors = ['#06b6d4', '#ec4899', '#22c55e', '#f59e0b', '#a78bfa']
all_x, all_y, all_z, all_c = [], [], [], []

for i in range(classes):
    angle = i * 2 * np.pi / classes
    cx = 3 * np.cos(angle)
    cy = 3 * np.sin(angle)
    cz = np.random.uniform(-1, 1)
    
    n = n_samples // classes
    x = np.random.normal(cx, 0.5, n)
    y = np.random.normal(cy, 0.5, n)
    z = np.random.normal(cz, 0.5, n)
    
    all_x.extend(x)
    all_y.extend(y)
    all_z.extend(z)
    all_c.extend([colors[i]] * n)

fig = plt.figure(figsize=(10, 8), facecolor='#0a0a0f')
ax = fig.add_subplot(111, projection='3d', facecolor='#0a0a0f')

ax.scatter(all_x, all_y, all_z, c=all_c, s=25, alpha=0.7, edgecolors='none')

ax.set_xlabel('Dim 1', color='white', fontsize=10)
ax.set_ylabel('Dim 2', color='white', fontsize=10)
ax.set_zlabel('Dim 3', color='white', fontsize=10)
ax.set_title('Neural Network Embeddings (t-SNE)', color='white', fontsize=14, fontweight='bold', pad=20)

ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')

ax.view_init(elev=25, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support