<s> """<STR_LIT>""" <EOL> import numpy as np <EOL> import rl <EOL> def ml_delta ( acc , states , res ) : <EOL> """<STR_LIT>""" <EOL> from itertools import product <EOL> from copy import deepcopy <EOL> params = ( ( <NUM_LIT> , <NUM_LIT:1> ) , ( <NUM_LIT> , <NUM_LIT:5> ) ) <EOL> param_values = [ np . arange ( * par , step = res ) for par in params ] <EOL> all_unique_param = product ( * param_values ) <EOL> best_log_L = None <EOL> best_par = ( ) <EOL> for alpha , beta in all_unique_param : <EOL> v_dict , rpe_dict = rl . reinforce . b_delta ( acc , states , alpha ) <EOL> v = rl . misc . unpack ( v_dict , states ) <EOL> p_values = np . array ( rl . policy . softmax ( v , states , beta ) ) <EOL> log_L = np . sum ( np . log ( p_values ) ) <EOL> if log_L > best_log_L : <EOL> print ( '<STR_LIT>' . format ( <EOL> log_L , alpha , beta ) ) <EOL> best_log_L = deepcopy ( log_L ) <EOL> best_par = ( alpha , beta ) <EOL> return ( best_par , best_log_L ) <EOL> def ml_delta_similarity ( acc , states , similarity , res ) : <EOL> """<STR_LIT>""" <EOL> from itertools import product <EOL> from copy import deepcopy <EOL> params = ( ( <NUM_LIT> , <NUM_LIT:1> ) , ( <NUM_LIT> , <NUM_LIT:5> ) ) <EOL> param_values = [ np . arange ( * par , step = res ) for par in params ] <EOL> all_unique_param = product ( * param_values ) <EOL> best_log_L = None <EOL> best_par = ( ) <EOL> for alpha , beta in all_unique_param : <EOL> v_dict , rpe_dict , acc_sim = rl . reinforce . b_delta_similarity ( <EOL> acc , states , similarity , alpha ) <EOL> v = rl . misc . unpack ( v_dict , states ) <EOL> p_values = np . array ( rl . policy . softmax ( v , states , beta ) ) <EOL> log_L = np . sum ( np . log ( p_values ) ) <EOL> if log_L > best_log_L : <EOL> print ( '<STR_LIT>' . format ( <EOL> log_L , alpha , beta ) ) <EOL> best_log_L = deepcopy ( log_L ) <EOL> best_par = ( alpha , beta ) <EOL> return ( best_par , best_log_L ) </s>
