<commit_before>import numpy as np
import time
from Neural_Networks import *

def Read_MNIST(training_set_images, training_set_labels, test_set_images, test_set_labels, number_training, number_test, image, target_output):
    # training set images
    file = open(training_set_images, 'rb')

    for _ in range(4):
        file.read(4)
        
    for h in range(number_training):
        for j in range(28 * 28):
            image[h][j] = int.from_bytes(file.read(1), byteorder='little') / 255
            
    file.close()

    # training set labels
    file = open(training_set_labels, 'rb')

    for _ in range(2):
        file.read(4)
        
    for h in range(number_training):
        label = int.from_bytes(file.read(1), byteorder='little')
        
        for j in range(10):
            target_output[h][j] = float(j == label)
            
    file.close()

    # test set images
    file = open(test_set_images, 'rb')

    for _ in range(4):
        file.read(4)
        
    for h in range(number_training, number_training + number_test):        
        for j in range(28 * 28):
            image[h][j] = int.from_bytes(file.read(1), byteorder='little') / 255
            
    file.close()

    # test set labels
    file = open(test_set_labels, 'rb')

    for _ in range(2):
        file.read(4)
        
    for h in range(number_training, number_training + number_test):
        label = int.from_bytes(file.read(1), byteorder='little')
        
        for j in range(10):
            target_output[h][j] = float(j == label)
            
    file.close()
    

batch_size = 60
decay_rate = 0.977
epsilon = 0.001
learning_rate = 0.005
number_iterations = 50
number_training = 60000
number_test = 10000

# train from scratch
NN = Neural_Networks()
<commit_msg>Update MNIST_CNN.py<commit_after>import numpy as np
import time
from Neural_Networks import *

def Read_MNIST(training_set_images, training_set_labels, test_set_images, test_set_labels, number_training, number_test, image, target_output):
    # training set images
    file = open(training_set_images, 'rb')

    for _ in range(4):
        file.read(4)
        
    for h in range(number_training):
        for j in range(28 * 28):
            image[h][j] = int.from_bytes(file.read(1), byteorder='little') / 255
            
    file.close()

    # training set labels
    file = open(training_set_labels, 'rb')

    for _ in range(2):
        file.read(4)
        
    for h in range(number_training):
        label = int.from_bytes(file.read(1), byteorder='little')
        
        for j in range(10):
            target_output[h][j] = float(j == label)
            
    file.close()

    # test set images
    file = open(test_set_images, 'rb')

    for _ in range(4):
        file.read(4)
        
    for h in range(number_training, number_training + number_test):        
        for j in range(28 * 28):
            image[h][j] = int.from_bytes(file.read(1), byteorder='little') / 255
            
    file.close()

    # test set labels
    file = open(test_set_labels, 'rb')

    for _ in range(2):
        file.read(4)
        
    for h in range(number_training, number_training + number_test):
        label = int.from_bytes(file.read(1), byteorder='little')
        
        for j in range(10):
            target_output[h][j] = float(j == label)
            
    file.close()
    

batch_size      = 60
decay_rate      = 0.977
epsilon         = 0.001
learning_rate   = 0.005
number_iterations = 50
number_training = 60000
number_test     = 10000

# train from scratch
NN = Neural_Networks()

{'fraction_non_alphanumeric': 0.10853794642857142, 'fraction_numerical': 0.03125, 'mean_word_length': 2.27996340347667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1421108', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1143, 'n_words': 279}