-
Notifications
You must be signed in to change notification settings - Fork 25
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
Using external CMAES library #103
base: master
Are you sure you want to change the base?
Conversation
@contextlib.contextmanager | ||
def avoid_printing(): | ||
save_stdout = sys.stdout | ||
sys.stdout = open('trash', 'w') |
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.
open('/dev/null', 'w')
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.
A couple minor annotations in the code, but overall very nice!!
Also, what's up with test/test.py
?
@@ -0,0 +1,123 @@ | |||
"""This module provides an experiment class which learns an instance | |||
of LTFArray with reliability based CMAES learner. |
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.
include reference to paper
seed_model, pop_size, step_size_limit, iteration_limit, | ||
): | ||
"""Initialize an Experiment using the Reliability based CMAES Learner for modeling LTF Arrays | ||
:param log_name: Log name, Prefix of the path or name of the experiment log file |
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.
I believe a path prefix is not good here
): | ||
"""Initialize an Experiment using the Reliability based CMAES Learner for modeling LTF Arrays | ||
:param log_name: Log name, Prefix of the path or name of the experiment log file | ||
:param seed_instance: PRNG seed used to create LTF array instances |
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.
we only init once, i.e. one instance (singular)
:param n: Length, the number stages within the LTF array | ||
:param noisiness: Noisiness, the relative scale of noise of instance compared to the scale of weights | ||
:param seed_challenges: PRNG seed used to sample challenges | ||
:param num: Challenge number, the number of binary inputs for the LTF array |
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's this?
:param noisiness: Noisiness, the relative scale of noise of instance compared to the scale of weights | ||
:param seed_challenges: PRNG seed used to sample challenges | ||
:param num: Challenge number, the number of binary inputs for the LTF array | ||
:param reps: Repetitions, the frequency of evaluations of every challenge (part of training_set) |
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.
use repetitions instead of frequency, as the latter suggests that this is an ongoing process (which it is not)
reliabilities = np.zeros(np.shape(delay_diffs)) | ||
indices_of_reliable = np.abs(delay_diffs[:]) > epsilon | ||
reliabilities[indices_of_reliable] = 1 | ||
correlation = this.calc_corr(reliabilities, measured_rels) |
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.
why not use __class__
here?
return False | ||
|
||
@staticmethod | ||
def common_responses(responses): |
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.
rename to majority
pypuf/tools.py
Outdated
self.challenges = array(list(sample_inputs(instance.n, N))) | ||
self.responses = instance.eval(self.challenges) | ||
self.challenges = array(list(sample_inputs(instance.n, N, random_instance=random_instance))) | ||
if reps is None: |
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.
move that to the function definition
pypuf/tools.py
Outdated
reps = 1 | ||
self.responses = zeros((reps, N)) | ||
for i in range(reps): | ||
self.challenges, cs = itertools.tee(self.challenges) |
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.
why are use assigning a value to self.challenges
here? I think it is unused and later overwritten. (Use _
instead?)
requirements.txt
Outdated
@@ -4,3 +4,4 @@ polymath | |||
pylint | |||
pep8 | |||
pypuf_helper | |||
cma |
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.
include an exact version here, e.g. 2.3.*
(this will update bug fixes but no major changes)
current unit test errors, also the tests were running for 12hrs+ |
65ee569
to
5551579
Compare
@nils-wisiol , please review my last commit within this pull request. |
174dbc3
to
077623b
Compare
I updated this branch to match up with the updated master branch. It is now, as far as I can tell, running without errors. However, I could not figure out parameters to learn an (relatively easy) instance with n=64 and k=2. For example,
i.e., n=64, k=2, nosiness 1, 10,000 CPRs, 30 samples per CRP and population size of 20 will stop after the maximum iteration count (500) with an accuracy of around 56%.
Variations of these parameters yield similar results. Could you include a couple of examples that give high accuracy results? |
077623b
to
0004837
Compare
0004837
to
83e9efe
Compare
We implemented a learner, experiment and console program concerning a reliability based CMAES attack on Arbiter PUFs. For optimality purposes we use an external library for applying a CMAES algorithm.
Up to now, only particular Arbiter PUFs can be learned.