-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_performance.py
More file actions
36 lines (27 loc) · 1.2 KB
/
plot_performance.py
File metadata and controls
36 lines (27 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pandas as pd
import matplotlib.pyplot as plt
file_path = 'performance_data.csv'
try:
df = pd.read_csv(file_path)
except FileNotFoundError:
print(f"Error: {file_path} not found. Please ensure the C++ program generated it.")
exit(1)
plt.figure(figsize=(12, 7))
plt.plot(df['HiddenSize'], df['StandardModel_ms'], label='Standard Model', marker='o')
plt.plot(df['HiddenSize'], df['OptimizedModel_ms'], label='Optimized Model', marker='o')
plt.plot(df['HiddenSize'], df['OpenMPModel_ms'], label='OpenMP Model', marker='o')
plt.title('Neural Model Training Time vs. Hidden Layer Size')
plt.xlabel('Hidden Layer Size')
plt.ylabel('Training Time (ms)')
plt.xscale('log', base=2) # Use log scale for hidden size if they are powers of 2
plt.xticks(df['HiddenSize'], labels=df['HiddenSize']) # Ensure all hidden sizes are shown as ticks
plt.legend()
plt.grid(True, which="both", ls="--", c='0.7')
# --- Save and show the plot ---
try:
plt.savefig('model_performance.png', dpi=300) # Save with higher resolution
print("Plot successfully saved as 'model_performance.png'")
except Exception as e:
print(f"Error encountered while saving the plot: {e}")
plt.show()
print("Performance plot displayed.")