"""Three.js 3D BDH Walkthrough — self-contained HTML for st.components.v1.html()""" def get_threejs_html(bdh_layer_activations, tf_layer_activations): import json, numpy as np N_NEURONS = 25 # 5×5 grid per layer def prep(stats_list, n=N_NEURONS): layers = [] for s in stats_list: acts = s["activations"].mean(0)[:n] acts = (acts - acts.min()) / (acts.max() - acts.min() + 1e-8) layers.append(acts.tolist()) return layers bdh_data = json.dumps(prep(bdh_layer_activations)) tf_data = json.dumps(prep(tf_layer_activations)) n_layers = len(bdh_layer_activations) return f"""