summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-09-10 19:28:45 +0200
committerandreas128 <Andreas>2017-09-10 19:28:45 +0200
commitdd46ed939e56a4e56c3dcec60cce1b93c8786a4a (patch)
treead37fba573a82a8d5ad82b764d74a80b4c198a9c
parent6e580248099ce4995ff0ba957d9f9ba64cfdfff2 (diff)
downloaddabmod-dd46ed939e56a4e56c3dcec60cce1b93c8786a4a.tar.gz
dabmod-dd46ed939e56a4e56c3dcec60cce1b93c8786a4a.tar.bz2
dabmod-dd46ed939e56a4e56c3dcec60cce1b93c8786a4a.zip
Use ridge regression
-rwxr-xr-xdpd/main.py2
-rw-r--r--dpd/src/Model.py14
2 files changed, 10 insertions, 6 deletions
diff --git a/dpd/main.py b/dpd/main.py
index 03520f5..5e67c90 100755
--- a/dpd/main.py
+++ b/dpd/main.py
@@ -64,7 +64,7 @@ parser.add_argument('--samplerate', default='8192000',
parser.add_argument('--coefs', default='poly.coef',
help='File with DPD coefficients, which will be read by ODR-DabMod',
required=False)
-parser.add_argument('--txgain', default=74,
+parser.add_argument('--txgain', default=71,
help='TX Gain',
required=False,
type=int)
diff --git a/dpd/src/Model.py b/dpd/src/Model.py
index 4ccf0be..827027a 100644
--- a/dpd/src/Model.py
+++ b/dpd/src/Model.py
@@ -13,7 +13,7 @@ logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFil
import numpy as np
import matplotlib.pyplot as plt
-
+from sklearn import linear_model
class Model:
"""Calculates new coefficients using the measurement and the old
@@ -25,8 +25,8 @@ class Model:
MER,
coefs_am,
coefs_pm,
- learning_rate_am=0.1,
- learning_rate_pm=0.1,
+ learning_rate_am=1.,
+ learning_rate_pm=1.,
plot=False):
self.c = c
self.SA = SA
@@ -124,7 +124,9 @@ class Model:
self.mses_am.append(mse)
self.errs_am.append(np.mean(err**2))
- a_delta = np.linalg.lstsq(rx_A, err)[0]
+ reg = linear_model.Ridge(alpha=0.00001)
+ reg.fit(rx_A, err)
+ a_delta = reg.coef_
new_coefs_am = self.coefs_am - self.learning_rate_am * a_delta
new_coefs_am = new_coefs_am * (self.coefs_am[0] / new_coefs_am[0])
return new_coefs_am
@@ -143,7 +145,9 @@ class Model:
err_phase = phase_diff_est - phase_diff_choice
self.errs_pm.append(np.mean(np.abs(err_phase ** 2)))
- p_delta = np.linalg.lstsq(phase_A, err_phase)[0]
+ reg = linear_model.Ridge(alpha=0.00001)
+ reg.fit(phase_A, err_phase)
+ p_delta = reg.coef_
new_coefs_pm = self.coefs_pm - self.learning_rate_pm * p_delta
return new_coefs_pm, phase_diff_choice