Skip to content

Commit f33f0d2

Browse files
committed
investigating feedback example
1 parent 7c197c0 commit f33f0d2

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

examples/Silverbox/silverbox_plot.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@
4545

4646
# In[Plot]
4747
fig, ax = plt.subplots(2, 1, sharex=True)
48-
ax[0].plot(t_fit, y_fit, 'k', label="$u")
48+
ax[0].plot(t_fit, y_fit, 'r', label="$y$")
4949
ax[0].grid()
50-
ax[1].plot(t_fit, u_fit, 'k', label="$y$")
50+
ax[0].set_ylabel('$y$')
51+
ax[1].plot(t_fit, u_fit, 'k', label="$u$")
5152
ax[1].grid()
52-
plt.legend()
53+
ax[1].set_ylabel('$u$')
54+
# plt.legend()
5355
plt.show()
5456

5557

examples/Silverbox/silverbox_train_feedback.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,20 @@
129129

130130
# In[Plot]
131131
plt.figure()
132-
plt.plot(t_fit, y_fit, 'k', label="$y$")
133-
plt.plot(t_fit, y_hidden, 'b', label="$\hat y$")
134-
plt.plot(t_fit, y_lin, 'r', label="$y_{lin}$")
132+
plt.plot(t_fit, y_fit, 'k', label="$y_{true}$")
133+
plt.plot(t_fit, y_hidden, 'b', label="$y_{FB}$")
134+
plt.plot(t_fit, y_lin, 'r', label="$y_{hat}$")
135135
plt.legend()
136+
plt.savefig(os.path.join(model_folder,'Feedback_fit.pdf'))
136137
plt.show()
137138

138139
plt.figure()
139-
plt.plot(LOSS)
140-
plt.plot(LOSS_FIT)
141-
plt.plot(LOSS_CONSISTENCY)
140+
plt.plot(LOSS, label='Total Loss')
141+
plt.plot(LOSS_FIT, label='Output Loss')
142+
plt.plot(LOSS_CONSISTENCY, label='Feedback Loss')
142143
plt.grid(True)
144+
plt.legend()
145+
plt.savefig(os.path.join(model_folder,'Feedback_train_loss.pdf'))
143146
plt.show()
144147

145148
# In[Plot static non-linearity]
@@ -155,9 +158,10 @@
155158
plt.figure()
156159
plt.plot(in_nl, out_nl, 'b')
157160
#plt.plot(y1_lin, y1_nl, 'b*')
158-
plt.xlabel('Static non-linearity input (-)')
159-
plt.ylabel('Static non-linearity input (-)')
161+
plt.xlabel('Static non-linearity input (hat)')
162+
plt.ylabel('Static non-linearity output (hat)')
160163
plt.grid(True)
164+
plt.savefig(os.path.join(model_folder,'F1_lin.pdf'))
161165
plt.show()
162166

163167
idx_plot_nl = np.abs(in_nl) > 0.02
@@ -166,8 +170,9 @@
166170
plt.figure()
167171
plt.plot(in_nl[idx_plot_nl], out_nl[idx_plot_nl]/in_nl[idx_plot_nl], 'b')
168172
plt.plot(y_hidden[idx_plot_h], y_nl[idx_plot_h] / y_hidden[idx_plot_h], 'b*')
169-
plt.xlabel('Static non-linearity input (-)')
170-
plt.ylabel('Static non-linearity input (-)')
173+
plt.xlabel('Static non-linearity input (FB)')
174+
plt.ylabel('Static non-linearity output (FB)')
175+
plt.savefig(os.path.join(model_folder,'F1_FB.pdf'))
171176
plt.grid(True)
172177
plt.show()
173178

0 commit comments

Comments
 (0)