cbadc.digital_estimator.adaptive_filter.AdaptiveIIRFilter
- class cbadc.digital_estimator.adaptive_filter.AdaptiveIIRFilter(M, K, L=1, dtype=<class 'numpy.float64'>)[source]
Bases:
AdaptiveFIRFilterThe adaptive IIR filter model.
Methods
__init__(M, K[, L, dtype])call(x)- param x
The input data, shape (nr_samples, M - nr_references).
Returns the FIR filter.
Returns the offset.
gradient(x, y)Computes the gradient of the loss function with respect to the filter coefficients.
impulse_response([number_of_points])Returns the impulse response of the filter.
lms(x, y[, delay])Fits the filter to the given data using the LMS method.
loss(x, y)Computes the loss function for the given FIR filter.
lstsq(x, y[, delay, x_validate, verbose])Fits the filter to the given data using the least squares method.
plot_bode([linear_frequency])Plots the Bode diagram for the filter.
Plots the impulse response of the filter for each channel.
predict(x)- param x
The input data batch.
predict_full(x, y)In contrast to the predict method, this method additionally removes the reference signals from the output.
rls(x, y[, delay])Fits the filter to the given data using the RLS method.
transfer_function([number_of_points])Returns the transfer function of the filter.
- call(x: ndarray)
- Parameters
x (np.ndarray (batch_size, M, K)) – The input data, shape (nr_samples, M - nr_references).
- Returns
y – The output data, shape (nr_samples, nr_references).
- Return type
np.ndarray (L, batch_size)
- get_filter()
Returns the FIR filter.
- Returns
h – The FIR filter.
- Return type
np.ndarray (L, M, K)
- get_offset()
Returns the offset.
- Returns
offset – The offset.
- Return type
np.ndarray (L,)
- gradient(x: ndarray, y: ndarray) List[ndarray]
Computes the gradient of the loss function with respect to the filter coefficients.
- Parameters
x (np.ndarray (batch_size, M, K)) – The input data.
y (np.ndarray (L, batch_size)) – The output data.
- Returns
gradient – The gradient of the loss function with respect to the filter coefficients.
- Return type
[np.ndarray (L, M, K), np.ndarray (L,)]
- impulse_response(number_of_points: int = 0)
Returns the impulse response of the filter.
- Parameters
number_of_points (int) – The number of uniformly spaced frequency points to evaluate the transfer function at, defaults to K.
- Returns
h – The impulse response.
- Return type
np.ndarray (L, M, K)
- lms(x: ndarray, y: ndarray, delay: int = 0, **kwargs)[source]
Fits the filter to the given data using the LMS method.
- Parameters
x (np.ndarray (batch_size, M)) – The input data.
y (np.ndarray (L, batch_size)) – The reference data.
delay (int) – The delay of the IIR filter. must be non-negative.
batch_size (int) – The batch size.
epochs (int) – The number of epochs.
learning_rate (float) – The learning rate, defaults to 1e-5.
momentum (float) – The momentum, defaults to 0.9.
verbose (bool) – Whether to print the loss function during training.
- Returns
loss – The loss function evaluated on the given data.
- Return type
np.ndarray (L,)
- loss(x: ndarray, y: ndarray)
Computes the loss function for the given FIR filter.
- Parameters
x (np.ndarray (batch_size, M, K)) – The input data.
y (np.ndarray (L, batch_size)) – The reference data.
- Returns
loss – The loss function evaluated on the given data.
- Return type
np.ndarray (L,)
- lstsq(x: ndarray, y: ndarray, delay: int = 0, x_validate: ndarray = None, verbose=True)[source]
Fits the filter to the given data using the least squares method.
- Parameters
- Returns
loss – The loss function evaluated on the given data.
- Return type
np.ndarray (L,)
- plot_bode(linear_frequency: bool = False)
Plots the Bode diagram for the filter.
- Mint
The number of channels.
- linear_frequencybool
If true, the frequency axis is linear, otherwise it is logarithmic.
- f_hmatplotlib.figure.Figure
The figure object.
- ax_hnumpy.ndarray
The axes objects.
- plot_impulse_response()
Plots the impulse response of the filter for each channel.
- Mint
The number of channels.
- f_hmatplotlib.figure.Figure
The figure object.
- ax_hnumpy.ndarray
The axes objects.
- predict(x: ndarray)[source]
- Parameters
x (np.ndarray (batch_size, M)) – The input data batch.
- Returns
y – The output data, shape (nr_samples, nr_references).
- Return type
np.ndarray (L, batch_size)
- predict_full(x, y)
In contrast to the predict method, this method additionally removes the reference signals from the output.
- Parameters
x (np.ndarray [batch_size, M, K]) – The input data, shape (nr_samples, M - nr_references).
y (np.ndarray [L, batch_size]) – The reference data.
- rls(x: ndarray, y: ndarray, delay: int = 0, **kwargs)[source]
Fits the filter to the given data using the RLS method.
- Parameters
x (np.ndarray (batch_size, M)) – The input data.
y (np.ndarray (L, batch_size)) – The reference data.
delay (int) – The delay of the IIR filter. must be non-negative.
epochs (int) – The number of epochs.
delta (float) – The delta parameter of the RLS algorithm.
lambda (float) – The lambda parameter of the RLS algorithm.
verbose (bool) – Whether to print the loss function during training.
- Returns
loss – The loss function evaluated on the given data.
- Return type
np.ndarray (L,)
- transfer_function(number_of_points: int = 0)[source]
Returns the transfer function of the filter.
- Parameters
number_of_points (int) – The number of uniformly spaced frequency points to evaluate the transfer function at, defaults to K.
- Returns
freqs (np.ndarray) – The frequency points.
tf (np.ndarray (L, M, number_of_points))