#NEWLINE# def save_password( real_password , noise_level = 5 ) : #NEWLINE# #INDENT# if ( noise < 1 ) : #NEWLINE# #INDENT# raise ValueError ( '`noise_level` must be equal or greater than 1.' ) #NEWLINE# #UNINDENT# binary_password = str2bin ( real_password ) #NEWLINE# bin_password_len = len ( binary_password ) #NEWLINE# data = [ binary_password ] #NEWLINE# for _ in range ( noise_level ) : #NEWLINE# #INDENT# noise = np . random . binomial ( 1 , 0.55 , bin_password_len ) #NEWLINE# data . append ( noise ) #NEWLINE# #UNINDENT# dhnet = algorithms . DiscreteHopfieldNetwork ( mode = 'sync' ) #NEWLINE# dhnet . train ( np . array ( data ) ) #NEWLINE# return dhnet