A List Based Neural Network that categorizes a letter based on its list representation.
- LetterNNET.py # Implementation file of LetterNNET.
- main.py # Main program file that makes full use of LetterNNET.
# Generated output files
- H_Training_set.txt # H data training set that is generated by the program.
- L_Training_set.txt # L data training set that is generated by the program.
- Test_data_set.txt # Contains random H and L list representations for program testing.
# NOTE: The last list is NOT part of the test data.
# It is the list that specifies the correct letter class for each list in the test_data.
# 1. generate_LETTER_Data: Generates letter list representations randomly and outputs it to a file.
def generateHData(file_name:str, data_size:int, num_noise:int):
def generateLData(file_name:str, data_size:int, num_noise:int):
file_name: Name of the output file for the generated data.
data_size: Number of H or L letter lists.
num_noise: Number of distorted elements for each letter list.
# 2. build_JmSet: Generates a list of random values that is used to sample from the letter lists
# when training or testing input data. The Jm set contains evenly
# divided tuples of size tuple_size.
def build_JmSet(list_length:int, tuple_size:int):
list_length: Must be the same length as the letter lists because we must generate valid indexes!
tuple_size: Size of the evenly divided tuples.
# 3. train_LETTER_set: Trains the neural network based on the letter list data provided
# by the data_fname file.
def trainHSet(data_fname:str, tuple_size:int, input_Jm=None):
def trainLSet(data_fname:str, tuple_size:int, input_Jm=None):
data_fname: Name of the ouput file containing the H or L letter lists.
tuple_size: Size of the tuoles that are used for sampling from the letter list.
OPTIONAL - input_Jm: A list containing valid indexes for sampling and training the neural network
if one is not provided the program will create one automatically and automatically save it to
its appropriate letter class Jm_set list.
# 4. generateSample: Generates a random set of H or L letter list representations that will
# be used as input for the neural network.
def generateSample(file_name:str, sample_size:int, num_noise:int):
file_name: Name of the output file for the generated data.
data_size: Number randomized letter lists.
num_noise: Number of distorted elements for each letter list.
# 5. sampleTesting: Uses the trained L and H data to guess the letter class of each
# list presentation from the input file.
def sampleTesting(sample_data_fname:str, tuple_size:int):
sample_data_fname: Name of the file containing the input letter lists.
tuple_size: Size of the tuples used for sampling.
AGAIN ---
NOTE: The last list is NOT part of the test data. It is the list that specifies the correct
letter class for each list in the test_data. If you want to provide custom sample data, make sure
the very last list is the sample_list containing the correct class letters where:
0: represents L in the ith letter list in sample data
1: represents H in the ith letter list in sample data
len(sample_data) == len(sample_letter_list)