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

Identifiers of BNN inputs and outputs in DIMACS file #43

Open
supratik1 opened this issue Apr 24, 2023 · 4 comments
Open

Identifiers of BNN inputs and outputs in DIMACS file #43

supratik1 opened this issue Apr 24, 2023 · 4 comments
Assignees

Comments

@supratik1
Copy link

Hi,
We are trying to use NPAQ for a slightly different application, and we need to know the identifiers corresponding to the BNN inputs and outputs in the DIMACS file that is generated.

For example, using the command
python npaq bnn --dataset mnist --resize 10,10 --num_classes 10 --arch 1blk_20 --encoder card encode

we get the DIMACS file and metainfo file as in the attached zip
npaq_files.zip
. It'll be great if the inputs and outputs of the BNN could also be indicated in comments in the DIMACS file.

@teobaluta teobaluta self-assigned this Apr 27, 2023
@teobaluta
Copy link
Owner

Hi Supratik,

Thanks for trying to use our tool! It should be easy to add some functionality to output that in the DIMACS output file but I am working for a deadline until May 5th so I have limited bandwidth until then. Nevertheless, will try to add it.

Teodora

@supratik1
Copy link
Author

Hi Teodora,
I was actually trying to work with NPAQ for a task with a deadline, and May 5 would be a bit too late for that. I was hoping it wouldn't be too much of an effort to simply output the indices of the input and output variables, since you probably know these already when you are doing the encoding. For example, the independent support should be the set of inputs, right?
I'd greatly appreciate if you can do this at the earliest. Don't worry about formatting the output properly if that's a problem. Just the list of output and input variable indices would be fine.

-Supratik

@teobaluta
Copy link
Owner

Hi Supratik,

The convention is that the input variables are allocated first (i.e., corresponding to the inputs), then the variables corresponding to the output. So if the inputs are 100 and the outputs are 10, we have 1-100 input vars and 101-110 for the output vars. Then the input variables to the intermediate block are allocated, and so on.

I was looking at the code and realized that the information about the input and output variables should be in the .metainfo file. This seems to match with the command you ran.

221
1 111 130
111 131 221 101 110

First line is the first fresh variable (not used for PB constraints), then the next line are all of the variables of the first block (and only one) starting from 1 to 111 because the output variables are reserved for 101 110 and the next available variable is 130. Then the output block (last layer) has the input variables111 131 and the next available variable is 221 (which is also the last one). The output variables are 101 110.

But I will have to do a more thorough check (most likely after my deadline). I hope this helps in the meantime to unblock you!

Thank you,
Teodora

For reference code where this is happening is

write_to_meta(this->out_dir, to_string(first_fresh_var));

to
write_to_meta(this->out_dir, to_string(in_var_start) + " " + \

@supratik1
Copy link
Author

Thanks a lot, Teodra. We'll go ahead with this for now. This also matches what we found by trial and error (was a bit of tedium). We look forward to hearing from you more authoritatively after your May 5 deadline.

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

2 participants