<jupyter_start><jupyter_text>Pretraining<jupyter_code>load_model('actor_critic4/critic_pretraining.tar')
load_model('actor_critic4a/critic_pretraining.tar')
load_model('actor_critic4b/critic_pretraining.tar')
# load_model('actor_critic4c/critic_pretraining.tar')
# load_model('actor_critic4d/critic_pretraining.tar')
load_model('actor_critic4e/critic_pretraining.tar')
compare_rewards_and_errors(
    ['actor_critic4/critic_pretraining',
     'actor_critic4a/critic_pretraining',
     'actor_critic4b/critic_pretraining',
     'actor_critic4e/critic_pretraining',
    ])
load_model('actor_critic5/critic_pretraining.tar')
load_model('actor_critic5a/critic_pretraining.tar')
# load_model('actor_critic5b/critic_pretraining.tar')
load_model('actor_critic5c/critic_pretraining.tar')
load_model('actor_critic6/critic_pretraining.tar')
compare_rewards_and_errors(
    ['actor_critic5/critic_pretraining',
     'actor_critic5a/critic_pretraining',
     'actor_critic5c/critic_pretraining',
     'actor_critic6/critic_pretraining',
    ])<jupyter_output><empty_output><jupyter_text>Main<jupyter_code>load_model('actor_critic4/main.tar')
load_model('actor_critic4a/main.tar')
load_model('actor_critic4b/main.tar')
load_model('actor_critic4c/main.tar')
load_model('actor_critic4d/main.tar')
load_model('actor_critic4e/main.tar')
compare_rewards_and_errors(
     [
        'actor_critic4/main',
        'actor_critic4a/main',
        'actor_critic4b/main',
        'actor_critic4c/main',
        'actor_critic4d/main',
        'actor_critic4e/main',
     ])
compare_per(
    ['actor_critic4/main',
     'actor_critic4a/main',
     'actor_critic4b/main',
     'actor_critic4c/main',
     'actor_critic4d/main',
     'actor_critic4e/main',])
load_model('actor_critic5/main.tar')
load_model('actor_critic5a/main.tar')
load_model('actor_critic5b/main.tar')
load_model('actor_critic5c/main.tar')
load_model('actor_critic6/main.tar')
# load_model('actor_critic7/main.tar')
# load_model('actor_critic7a/main.tar')
load_model('actor_critic7b/main.tar')
load_model('actor_critic7c/main.tar')
load_model('actor_critic7d/main.tar')
compare_rewards_and_errors(
     [
        'actor_critic5/main',
        'actor_critic5a/main',
        'actor_critic5b/main',
        'actor_critic5c/main',
        'actor_critic6/main',
     ])
compare_rewards_and_errors(
    ['actor_critic7/main', 
     'actor_critic7a/main', 
     'actor_critic7b/main',
     'actor_critic7c/main',
     'actor_critic7d/main'])
compare_per(
     [
        #'actor_critic5/main',
        #'actor_critic5a/main',
        #'actor_critic5c/main',
        'actor_critic7/main',
        'actor_critic7a/main',
        'actor_critic7b/main',
        'actor_critic7c/main',
        'actor_critic7d/main',
     ])
compare_entropies(
    [
        'actor_critic4/main',
        'actor_critic4e/main',
        'actor_critic5/main',
        'actor_critic5a/main',
        'actor_critic7/main',
        'actor_critic7a/main',
        'actor_critic7b/main',
        'actor_critic7c/main',        
    ],
)<jupyter_output><empty_output><jupyter_text>Analysis<jupyter_code>def print_critic_suggestions(it, i, just_from_groundtruth=False, n_best=5):
    print "Groundtruth: ", groundtruth[it][i]
    print "Prediction: ", predictions[it][i]
    print "Rewards: ", rewards[it][:, i]
    groundtruth_nums = set([char2code[word] for word in groundtruth[it][i]])
    predictions_words = predictions[it][i]
    for step in range(len(predictions_words)):
        actions = enumerate(values[it][step, i])
        if just_from_groundtruth:
            actions = [(n, q) for n, q in actions if n in groundtruth_nums]
        best = list(sorted(actions, key=lambda (i, o): -o))
        print [(code2char[c], o, probs[it][step, i , c]) for c, o in best[:n_best]]
        if predictions_words[step] == '$':
            break
            
def show_probs(it, i):
    pyplot.matshow(probs[it][:, i])
    pyplot.colorbar()
    pyplot.show()            
            
def show_values(it, i):
    pyplot.matshow(values[it][:, i])
    pyplot.colorbar()
    pyplot.show()
load_model('actor_critic7/critic_pretraining.tar')
log = logs['actor_critic7/critic_pretraining']
print log.status['iterations_done']
print log.status['_config']
train_cost = [log[t].get('train_cost') for t in range(0, log.status['iterations_done'])]
rewards = [log[t].get('readout_costs_rewards') for t in range(0, log.status['iterations_done'])]
mean_reward = [log[t].get('mean_total_reward') for t in range(0, log.status['iterations_done'])]
critic_cost = [log[t].get('readout_costs_mean_critic_cost') for t in range(0, log.status['iterations_done'])]
actor_cost = [log[t].get('readout_costs_mean_actor_cost') for t in range(0, log.status['iterations_done'])]

inputs = [log[t].get('average_inputs') for t in range(0, log.status['iterations_done'])]
predictions = [log[t].get('average_predictions') for t in range(0, log.status['iterations_done'])]
prediction_masks = [log[t].get('readout_costs_prediction_mask') for t in range(0, log.status['iterations_done'])]
groundtruth = [log[t].get('average_groundtruth') for t in range(0, log.status['iterations_done'])]

value_biases = [log[t].get('readout_costs_value_biases') for t in range(0, log.status['iterations_done'])]
values = [log[t].get('readout_costs_values') for t in range(0, log.status['iterations_done'])]
probs = [log[t].get('readout_costs_probs') for t in range(0, log.status['iterations_done'])]
outputs = [log[t].get('readout_costs_outputs') for t in range(0, log.status['iterations_done'])]

prediction_values = [log[t].get('readout_costs_prediction_values') for t in range(0, log.status['iterations_done'])]
prediction_outputs = [log[t].get('readout_costs_prediction_outputs') for t in range(0, log.status['iterations_done'])]

value_targets = [log[t].get('readout_costs_value_targets') for t in range(0, log.status['iterations_done'])]
it = 29800 # training iteration
print mean_reward[it]
#print rewards[t].sum(axis=0)
print train_cost[it], critic_cost[it], actor_cost[it]
print "Groundtruth"
pprint(groundtruth[it])
print "Predictions"
pprint(predictions[it])
i = 3
print_critic_suggestions(it, i)
show_probs(it, i)
show_values(it, i)
print prediction_values[it][:, i][:-3]
print [probs[it][t, i, char2code[c]] for t, c in enumerate(predictions[it][i])][:-3]
print value_targets[it][:, i][:-3]
print ((prediction_values[it][:, i] - value_targets[it][:, i]) ** 2)[:-3].sum()
print (probs[it][:, i] * values[it][:, i]).sum(axis=-1)[1:]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15344483658124905, 'fraction_numerical': 0.016725487187356145, 'mean_word_length': 5.219465648854962, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '188660', 'license': 'MIT', 'n_tokens_mistral': 2515, 'n_tokens_neox': 2478, 'n_words': 330, 'path': 'exp/billion_words/Autoencoder3.ipynb', 'repo_name': 'Fatman003/Actor', 'size': '6517'}