-
Notifications
You must be signed in to change notification settings - Fork 0
update normalisation for average kersize #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ def diams_feasibleset(feasible_set_y, p_1 ,p): | |
| - p: Order of the average kernel size. Set to p=2 for the MSE lower bound computation and p=1 for MAE lower bound computation. | ||
|
|
||
| Returns: | ||
| - diameter_mean_y, num_feas, max_diam_Fy: diameter_mean_y of dim(0)= shape(input_data), the estimated mean diameter of the feasible set to the power p, | ||
| - diameter_mean_y, num_feas, max_diam_Fy: diameter_mean_y of dim(0)= shape(input_data), the estimated "mean" | ||
| (normalized by num_feas-1, i.e. lacking a factor num_feas) diameter of the feasible set to the power p, | ||
| consisting of all possible target data points, for one input point. | ||
| num_feas is the number of samples in the feasible set and will be used for statistics later on. | ||
| max_diam_Fy the maximum diameter of the feasible set, | ||
|
|
@@ -44,10 +45,10 @@ def diams_feasibleset(feasible_set_y, p_1 ,p): | |
|
|
||
| # get mean over diams, with factor 2 due to symmetry of the norm of the compute vectors in null space of F (norm(x-z)=norm(z-x)) | ||
| # and divided by num_feas^2 ad we have that many terms | ||
| if num_feas > 0: | ||
| # compute 2 times sum over diams to the power p divided by num_feas^2 | ||
| diameter_mean_y = 2*np.divide(np.sum(np.power(diam_y,p)), np.power(num_feas,2)) | ||
| elif num_feas==0: | ||
| if num_feas > 1: | ||
| # compute 2 times sum over diams to the power p divided by num_feas-1 | ||
| diameter_mean_y = 2*np.divide(np.sum(np.power(diam_y,p)), num_feas-1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please double check that this is correct and align with comment above
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not (num_feas-1)^p ? |
||
| else: | ||
| diameter_mean_y = 0 | ||
|
|
||
| return diameter_mean_y, num_feas, max_diam_Fy | ||
|
|
@@ -173,16 +174,18 @@ def average_kernelsize(feasible_sets_list, p_1, p): | |
|
|
||
| average_kersize = 0 | ||
| num_samples = len(feasible_sets_list) | ||
| normalization_m=0 | ||
|
|
||
| for feasible_set_y in feasible_sets_list: | ||
| # compute diameter of feasible set for one input data point (num_feas will be used for statistics later on) | ||
| diameter_mean_y, num_feas, max_diam_Fy = diams_feasibleset(feasible_set_y, p_1 ,p) | ||
| #add diameters means for obtaining average kersize to the power p | ||
| average_kersize = average_kersize + diameter_mean_y | ||
| normalization_m = normalization_m+num_feas | ||
|
|
||
| # get mean over input data | ||
| if average_kersize>0 and num_samples > 0: | ||
| average_kersize = np.divide(average_kersize, num_samples) | ||
| average_kersize = np.divide(average_kersize, normalization_m) | ||
| else: | ||
| average_kersize = 0 | ||
| # take power 1/p to obtain average kersize | ||
|
|
@@ -225,4 +228,3 @@ def average_kernelsize_sym(A, input_data, target_data, p_1, p_2, p, epsilon): | |
| average_kersize_sym = np.power(average_kersize_sym, 1/p) | ||
|
|
||
| return average_kersize_sym | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens for case num_feas == 1?