<commit_before>#!/usr/bin/env python

"""Train this model with supervised layer-wise pretraining."""

import os
import shutil
import json

import logging
import sys

logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                    level=logging.DEBUG,
                    stream=sys.stdout)

# Make model with one hidden layer
logging.info("Make model with one hidden layer")
os.chdir("../baseline-1-c2")
if not os.path.isfile("model-1.json"):
    os.system("train.py")
shutil.copyfile("model-1.json", "../baseline-2-c2/model-1.json")

# Remove last layer
logging.info("Remove last layer")
with open("model-1.json") as f:
    model = json.load(f)
model['layers'].pop()

# Make new layer
os.chdir("../baseline-2-c2")
os.system("detl make mlp 500:500:369 > layer2.json")
os.system("detl stack model-1.json layer2.json > model-2.json")
os.system("rm layer2.json")

logging.info("Train it")
os.system("train.py")
<commit_msg>models/baseline-2-c2/training.py: Write model file after last layer has been discarded<commit_after>#!/usr/bin/env python

"""Train this model with supervised layer-wise pretraining."""

import os
import shutil
import json

import logging
import sys

logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                    level=logging.DEBUG,
                    stream=sys.stdout)

# Make model with one hidden layer
logging.info("Make model with one hidden layer")
os.chdir("../baseline-1-c2")
if not os.path.isfile("model-1.json"):
    os.system("train.py")
shutil.copyfile("model-1.json", "../baseline-2-c2/model-1.json")

# Remove last layer
logging.info("Remove last layer")
with open("model-1.json") as f:
    model = json.load(f)
model['layers'].pop()
with open("model-1.json", "w") as f:
    json.dump(model, f)

# Make new layer
os.chdir("../baseline-2-c2")
os.system("detl make mlp 500:500:369 > layer2.json")
os.system("detl stack model-1.json layer2.json > model-2.json")
os.system("rm layer2.json")

logging.info("Train it")
os.system("train.py")

{'fraction_non_alphanumeric': 0.1661721068249258, 'fraction_numerical': 0.025222551928783383, 'mean_word_length': 3.874698795180723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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}}
{'dir': 'git-commits-cleaned', 'id': '3288670', 'n_tokens_mistral': 722, 'n_tokens_neox': 687, 'n_words': 166}