Update modeling_super_linear.py
Browse files355 unmodified lines3563573583593603613623631 unmodified line365366367368369370371372373374375366376377378379380355 unmodified lines load_balancing_loss = self.calculate_load_balancing_loss(self.gate_outputs, batch_size)
expert_probs = F.softmax(self.gate_outputs, dim=1) expert_probs = expert_probs[1,:] # Plot the expert probabilities import matplotlib.pyplot as plt
plt.figure(figsize=(10, 6))1 unmodified line plt.xlabel('Expert Index') plt.ylabel('Probability') plt.title('Expert Selection Probabilities') # Create more descriptive x-axis labels if hasattr(self, 'experts') and isinstance(getattr(self, 'experts', None), dict): # If experts are stored in a dictionary with meaningful keys expert_names = list(self.experts.keys()) plt.xticks(range(len(expert_probs)), expert_names, rotation=45) else: # Default numbering if expert names aren't available plt.xticks(range(len(expert_probs)), [f'Expert {i}' for i in range(len(expert_probs))]) plt.xticks(range(len(expert_probs)), [f'Expert {i}' for i in range(len(expert_probs))]) plt.tight_layout() plt.savefig('expert_probabilities.png') plt.close()modeling_super_linear.py+12-1