Bad output in witness file #633
-
Looks like the output from running the compiled circuit is contained in the witness file, where each element is encoded as a 4-tuple of uint64. I created a simple CNN for MNIST, which outputs a 1d vector of length 10. One (out of 10) element of the circuit output is:
When trying to convert this back to a field element with the following function:
I get this error:
In addition, ignoring elements of the output vector that fail to convert, the result is still off compared to the original CNN. The max-valued index in the original CNN output gives the correct prediction, whereas the max-valued index in the circuit output does not. Maybe this is due to quantization error since I used the "resources" setting calibration strategy? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
sample usage is as such message = [1.0, 2.0, 3.0, 4.0]
message = [ezkl.float_to_vecu64(x, 7) for x in message]
res = ezkl.poseidon_hash(message)
assert ezkl.vecu64_to_felt(
res[0]) == "0x0da7e5e5c8877242fa699f586baf770d731defd54f952d4adeb85047a0e32f45"
|
Beta Was this translation helpful? Give feedback.
Ah sorry had just copy pasted one of our tests -- hash has nothing to do with it.
ezkl.float_to_vecu64 scales up the provided input using the passed in scale (in your case 7 -- so
1 -> 1 * 2^7 = 128
). This is to reduce numerical accuracy loss when converting floating point numbers to field elementsIf you want to round trip the serialization in full you can use ezkl.vecu64_to_float and pass in the used scale (in this case 7):