Skip to content
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

Unable to get good parameters from rational fitting #15

Open
boonta opened this issue Apr 15, 2021 · 9 comments
Open

Unable to get good parameters from rational fitting #15

boonta opened this issue Apr 15, 2021 · 9 comments

Comments

@boonta
Copy link

boonta commented Apr 15, 2021

I tried the tutorial on this page with the same material.

http://alta.gforge.inria.fr/tutorial2.html

However, my L2 error is bigger than what was provided in the tutorial page.

This is the header from ' http://alta.gforge.inria.fr/rational-example-01.brdf '.

#CMD --L2 0.0142601 --Linf 0.240069 --fitter rational_fitter_leastsquare --func rational_function_chebychev

This is the header following the tutorial.

#CMD --L2 3.25913 --Linf 231.828 --fitter rational_fitter_leastsquare --func rational_function_chebychev

My L2 error is bigger than what it should be.

Could it be any bug in the code ?

@belcour
Copy link
Owner

belcour commented Apr 15, 2021

Hi boonta,

Here is the output when I run tutorial2 on my machine:

<<DEBUG>> The file format is undefined, assuming TEXT
<<INFO>> the input parametrization is UNKNOWN_INPUT
<<INFO>> Starting to load file ... 
<<INFO>> loaded input stream
<<INFO>> loaded data input of R^1 -> R^1
<<DEBUG>> 604 double loaded. 
<<INFO>> 151 elements (rows) loaded
<<WARNING>> both function and data objects have no parametrization
<<INFO>> np =10& nq =10
<<INFO>> got solution p = [47.6775, -617.513, -1307.11, 4517.58, 8953.67, -6573.13, -18311.1, -1869.04, 11015.4, 4940.73]
q = [1, -14.3498, -6.94126, 98.4653, 42.6791, -148.834, -131.163, 40.2715, 90.308, 37.2092]

<<INFO>> got a fit
<<INFO>> it took 0h 0m 0s
<<INFO>> total time: 0h 0m 0s
<<INFO>> Mean = [-0.000208498], Var = [0.000780856]
<<INFO>> L2   distance to data = 0.0279415
<<INFO>> Linf distance to data = 0.27124

You should obtain something similar. Can you drop your output? Also, there might be differences between platforms (however not that big). Could you provide the configuration you use to test this?

Cheers

@boonta
Copy link
Author

boonta commented Apr 15, 2021

Environment : ubuntu18 (on docker)

Commands used to generate my output

data2data --input gold-metallic-paint.binary --in-data data_merl --output gold-metallic-paint.exr --out-data data_brdf_slice --param RUSIN_TH_TD
data2data --input gold-metallic-paint.exr --in-data data_brdf_slice --output gold-metallic-paint.alta
data2brdf --input gold-metallic-paint.alta --output gold-metallic-paint.func --func rational_function_chebychev --fitter rational_fitter_leastsquare --np 10 --nq 10

Output


<<INFO>> Data Loaded in 0h 0m 0s
<<INFO>> parsed input parametrization RUSIN_TH_TD from name "RUSIN_TH_TD"
<<INFO>> parsed input parametrization RUSIN_TH_TD from name "RUSIN_TH_TD"
<<INFO>> Specified param "RUSIN_TH_TD"
<<INFO>> Conversion from RUSIN_TH_TD_PD to RUSIN_TH_TD
<<INFO>> Dimensions for  Input Data [X,Y] = 3, 3
<<DEBUG>> Loading a v2 EXR file
<<DEBUG>> Loading a 3 channels EXR file
<<DEBUG>> Loading a 512x512 EXR file
<<INFO>> Data Loaded in 0h 0m 0s
<<INFO>> the input parametrization is UNKNOWN_INPUT
<<DEBUG>> using the input parametrization of the input file for the output file as well.
<<INFO>> Conversion from STARK_2D to STARK_2D
<<INFO>> Dimensions for  Input Data [X,Y] = 2, 3
<<INFO>> Dimensions for Output Data [X,Y] = 2, 3
<<INFO>> Number of Invalid Configurations = 56246 over 262144 configurations
<<INFO>> Data saved to file in 0h 0m 0s
<<DEBUG>> The file format is undefined, assuming TEXT
<<INFO>> parsed input parametrization STARK_2D from name "STARK_2D"
<<INFO>> Starting to load file ...
<<INFO>> loaded input stream
<<INFO>> loaded data input of R^2 -> R^3
<<DEBUG>> 2883584 double loaded.
<<INFO>> 262144 elements (rows) loaded
<<DEBUG>> no change was made to the parametrization
<<INFO>> Fitting using np = 10 & nq = 10
<<INFO>> L_2 0.191698 ; L_inf 0.250083 ; L_1  0.22109
<<INFO>> got solution p = [0.0490937, 0.0399836, 0.0572058, 0.0287579, 0.0784397, 0.00571869, 0.0136293, 0.0330401, 0.0157481, 0.0023422]
q = [1, 1.1683, -1.13286, 0.180531, -1.41598, 0.158661, -0.0278788, -0.295093, 0.174498, 0.0162104]

<<INFO>> L_2 0.197027 ; L_inf 0.224064 ; L_1  0.227805
<<INFO>> got solution p = [0.0284017, 0.0245548, 0.0412024, 0.0164771, 0.0586003, 0.00684025, 0.00776192, 0.023434, 0.01184, 0.00151426]
q = [1, 1.26014, -0.832342, 0.291166, -1.04637, 0.0823609, 0.00237003, -0.22282, 0.0966515, 0.0143242]

<<INFO>> L_2 0.110153 ; L_inf 0.196859 ; L_1  0.153258
<<INFO>> got solution p = [0.00717329, 0.00510938, 0.010866, 0.00362682, 0.0164488, 0.00411427, 0.00227574, 0.00772549, 0.00510476, 0.000281679]
q = [1, 1.29222, -0.99048, 0.326822, -1.25287, 0.0773896, 0.014105, -0.272643, 0.0933023, 0.0133702]

<<INFO>> got a fit, it took 0h 0m 23s
<<INFO>> total time: 0h 0m 23s
<<INFO>> Mean = [-6.41533e-15, -4.43426e-13, 6.70303e-13], Var = [0.00278636, 0.00162989, 0.000284156]
<<INFO>> L2   distance to data = 0.0685595
<<INFO>> Linf distance to data = 0.463686

L2 distance to data is 3 times bigger than what you get.

@boonta
Copy link
Author

boonta commented Apr 15, 2021

Could it be possible that the solver does not guarantee the global minimum solution ?
The initial seed of the solver might have the impact to the optimization.

I tried on a different machine with the same docker environment. I get a different result. But it is still not a good result.

@belcour
Copy link
Owner

belcour commented Apr 15, 2021

@boonta maybe the difference in error is due to the fact that you are not using the same number of coefficients as in the tutorial. nq and np are not set to 10 there.

The least-square solver is deterministic, but differences in output could be due to difference in compiler optimization (for exemple when using fast-math on GCC).

@boonta
Copy link
Author

boonta commented Apr 15, 2021

I have 2 machines running the same environment (ubuntu18 on docker).

Machine A
np = 10
nq = 10
L2 distance to data ~ 0.06

Machine B
np = 10
nq = 10
L2 distance to data ~ 36

What could possibly result in this big error gap ?

@boonta
Copy link
Author

boonta commented Apr 22, 2021

Hello @belcour ,
I just found out that your data is not the same as tutorial.

<<INFO>> loaded data input of R^1 -> R^1
<<DEBUG>> 604 double loaded. 
<<INFO>> 151 elements (rows) loaded

You loaded data of R1 --> R1 which has 151 elements.

However, the tutorial should have R2-> R1 which have 262144 elements.

<<INFO>> loaded data input of R^2 -> R^3
<<DEBUG>> 2883584 double loaded.
<<INFO>> 262144 elements (rows) loaded

Secondly, could that be the case that your code might be different from codes from Github ?

Lastly,
The http://alta.gforge.inria.fr/ refers to gitlab.

$ git clone https://gitlab.inria.fr/alta/alta.git
$ git checkout v0.2

The codes I used were checkout from this github.

@belcour
Copy link
Owner

belcour commented Apr 22, 2021 via email

@larsgrobe
Copy link

It would be helpful to clarify the status of this repo with regards to https://gitlab.inria.fr. Is the latter the more recent?

@belcour
Copy link
Owner

belcour commented Aug 31, 2023

The gitlab repo is the main one. This github is a personnal fork to experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants