From 68006de8c000c031a906b30529c745552f2e957e Mon Sep 17 00:00:00 2001 From: art Date: Tue, 29 Oct 2019 09:41:49 -0500 Subject: [PATCH] titanlearn.py v 2.0.0.000 --- data analysis/analysis/analysis.py | 8 ++--- data analysis/analysis/regression.py | 6 ++-- data analysis/analysis/titanlearn.py | 52 ++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 data analysis/analysis/titanlearn.py diff --git a/data analysis/analysis/analysis.py b/data analysis/analysis/analysis.py index fc1b2806..de2b8a49 100644 --- a/data analysis/analysis/analysis.py +++ b/data analysis/analysis/analysis.py @@ -1,10 +1,10 @@ # Titan Robotics Team 2022: Data Analysis Module # Written by Arthur Lu & Jacob Levine # Notes: -# this should be imported as a python module using 'import analysis' -# this should be included in the local directory or environment variable -# this module has been optimized for multhreaded computing -# current benchmark of optimization: 1.33 times faster +# this should be imported as a python module using 'import analysis' +# this should be included in the local directory or environment variable +# this module has been optimized for multhreaded computing +# current benchmark of optimization: 1.33 times faster # setup: __version__ = "1.1.5.001" diff --git a/data analysis/analysis/regression.py b/data analysis/analysis/regression.py index 35893f50..0983d3bc 100644 --- a/data analysis/analysis/regression.py +++ b/data analysis/analysis/regression.py @@ -1,9 +1,9 @@ # Titan Robotics Team 2022: CUDA-based Regressions Module # Written by Arthur Lu & Jacob Levine # Notes: -# this should be imported as a python module using 'import regression' -# this should be included in the local directory or environment variable -# this module is cuda-optimized and vectorized (except for one small part) +# this should be imported as a python module using 'import regression' +# this should be included in the local directory or environment variable +# this module is cuda-optimized and vectorized (except for one small part) # setup: __version__ = "1.0.0.002" diff --git a/data analysis/analysis/titanlearn.py b/data analysis/analysis/titanlearn.py new file mode 100644 index 00000000..c936a2e1 --- /dev/null +++ b/data analysis/analysis/titanlearn.py @@ -0,0 +1,52 @@ +# Titan Robotics Team 2022: ML Module +# Written by Arthur Lu & Jacob Levine +# Notes: +# this should be imported as a python module using 'import titanlearn' +# this should be included in the local directory or environment variable +# this module is optimized for multhreaded computing +# this module learns from its mistakes far faster than 2022's captains +# setup: + +__version__ = "2.0.0.000" + +#changelog should be viewed using print(analysis.__changelog__) +__changelog__ = """changelog: +2.0.0.000: + - complete rewrite planned + - depreciated 1.0.0.xxx versions + - added simple training loop +1.0.0.xxx: + -added generation of ANNS, basic SGD training +""" + +__author__ = ( + "Arthur Lu , " + "Jacob Levine ," + ) + +__all__ = [ + 'train', + ] + +import torch +import torch.optim as optim + +def train(device, net, epochs, trainloader, optimizer, criterion): + + for epoch in range(epochs): # loop over the dataset multiple times + + for i, data in enumerate(trainloader, 0): + + inputs = data[0].to(device) + labels = data[1].to(device) + + optimizer.zero_grad() + + outputs = net(inputs) + loss = criterion(outputs, labels.to(torch.float)) + + loss.backward() + optimizer.step() + + return net + print("finished training") \ No newline at end of file