<jupyter_start><jupyter_text>Single-element conditioning<jupyter_code>one_element_template = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]
ix_to_element = {
    0 : "question",
    1 : "coin",
    2 : "enemy",
    3 : "pipe",
    4 : "cannon",
}
element_to_ix = {v:k for k, v in ix_to_element.items()}
for i in range(5):
    tape = template.copy()
    tape[i] = one_element_template
    with open(f'./condition_tapes/{ix_to_element[i]}_tape.json', 'w+') as json_f:
        json.dump(tape.tolist(), json_f)<jupyter_output><empty_output><jupyter_text>Double-element conditioning (alternate) - question + coin- question + enemy- question + pipe- question + cannon- coin + enemy- coin + pipe- coin + cannon- enemy + pipe- enemy + cannon- pipe + cannon<jupyter_code>ix_to_pair = {
    0 : "question_coin",
    1 : "question_enemy",
    2 : "question_pipe",
    3 : "question_cannon",
    4 : "coin_enemy",
    5 : "coin_pipe",
    6 : "coin_cannon",
    7 : "enemy_pipe",
    8 : "enemy_cannon",
    9 : "pipe_cannon"
}
two_element_template_1 = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]
two_element_template_2 = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]
for i in range(len(ix_to_pair.keys())):
    tape = template.copy()
    pair = ix_to_pair[i]
    element_one, element_two = pair.split('_')
    tape[element_to_ix[element_one]] = two_element_template_1
    tape[element_to_ix[element_two]] = two_element_template_2
    with open(f'./condition_tapes_double_alternate/{pair}_tape.json', 'w+') as json_f:
        json.dump(tape.tolist(), json_f)<jupyter_output><empty_output><jupyter_text>Single-element mix tape<jupyter_code>num_chunks = 10
tape_height = 5
chunk_width = 16
tape_len = num_chunks * chunk_width
def get_random_tape_int(tape_len, tape_height):
    tape_int = []
    while len(tape_int) <= tape_len - 2:
        tile_ix = np.random.randint(0, tape_height)
        tape_int.extend([tile_ix, tile_ix])
        if len(tape_int) <= tape_len - 2:
            tape_int.extend([tape_height, tape_height])
    return tape_int
def get_random_tape(tape_len, tape_height):
    tape = np.zeros((tape_height, tape_len))
    for i, ix in enumerate(get_random_tape_int(tape_len, tape_height)):
        if ix != 5: tape[ix, i]=1
    return tape
tape_dir = 'condition_tapes_single_alternate'
np.random.seed(42)
for i in range(10):
    with open(f'{tape_dir}/random_tape_{i}.json', 'w+') as json_f:
        json.dump(get_random_tape(tape_len, tape_height).tolist(), json_f)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14661354581673305, 'fraction_numerical': 0.03266932270916335, 'mean_word_length': 3.9526627218934913, 'pattern_counts': {'":': 0, '<': 15, '<?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': '548860', 'license': 'MIT', 'n_tokens_mistral': 1068, 'n_tokens_neox': 1008, 'n_words': 214, 'path': 'notebooks/.ipynb_checkpoints/create_condition_tapes-checkpoint.ipynb', 'repo_name': 'zhihanyang2022/mario_conditional_lstm', 'size': '2510'}