Skip to content

Commit a7dc9dc

Browse files
v9.0
AI Tests
1 parent cbb475c commit a7dc9dc

24 files changed

+174
-40
lines changed
1.63 KB
Binary file not shown.
4.92 KB
Binary file not shown.

AI/aiScoring.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import time
2+
from AI.aiTests import *
3+
4+
5+
def score(_in, device, test: int = 1, inputSize: int = 16, hx: int = 32, outputSize: int = 1, numLayers: int = 24, model = "google/gemma-3-270m", type: str = "text-generation"):
6+
startTimer = time.perf_counter()
7+
startTimer2 = time.process_time()
8+
9+
change = 0 # Placeholder for HuggingFace
10+
11+
if test == 1:
12+
SimpleNeuralNet(inputSize, hx, outputSize).to(device)(_in)
13+
elif test == 2:
14+
RNN(inputSize, hx, outputSize, numLayers).to(device)(_in)
15+
elif test == 3:
16+
LargeNeuralNet(inputSize, hx, outputSize, numLayers).to(device)(_in)
17+
elif test == 4:
18+
HuggingFace(model, device, type).model(_in)
19+
change = 100
20+
else:
21+
SimpleNeuralNet(inputSize, hx, outputSize).to(device)(_in)
22+
23+
endTimer = time.perf_counter()
24+
endTimer2 = time.process_time()
25+
26+
totalTime = (endTimer - startTimer) + (endTimer2 - startTimer2)
27+
points = (1000 // totalTime * 0.1) + change
28+
return f"AI Score: {points} | Time Taken: {totalTime}s"

AI/aiTests.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
from torch import nn
2+
3+
4+
class SimpleNeuralNet(nn.Module):
5+
def __init__(self, inputSize: int = 16, hx: int = 32, outputSize: int = 1):
6+
super(SimpleNeuralNet, self).__init__()
7+
self.inputSize = inputSize
8+
self.hx = hx
9+
self.outputSize = outputSize
10+
11+
def forward(self, x):
12+
net = nn.Sequential(
13+
nn.Linear(self.inputSize, self.hx),
14+
nn.ReLU(),
15+
nn.Linear(self.hx, self.outputSize),
16+
nn.Sigmoid()
17+
)
18+
19+
return net
20+
21+
class RNN(nn.Module):
22+
def __init__(self, inputSize: int = 16, hx: int = 32, outputSize: int = 1, numLayers: int = 24):
23+
super(RNN, self).__init__()
24+
self.inputSize = inputSize
25+
self.hx = hx
26+
self.outputSize = outputSize
27+
self.numLayers = numLayers
28+
29+
def forward(self, x):
30+
rnn = nn.Sequential(
31+
nn.RNN(self.inputSize, self.hx, self.numLayers),
32+
nn.Linear(self.inputSize, self.hx),
33+
nn.ReLU(),
34+
nn.Linear(self.hx, self.outputSize),
35+
nn.Sigmoid()
36+
)
37+
38+
return rnn
39+
40+
class LargeNeuralNet(nn.Module):
41+
def __init__(self, inputSize: int = 16, hx: int = 32, outputSize: int = 1):
42+
super(LargeNeuralNet, self).__init__()
43+
self.inputSize = inputSize
44+
self.hx = hx
45+
self.outputSize = outputSize
46+
47+
def forward(self, x):
48+
net = nn.Sequential(
49+
nn.LSTM(self.inputSize, self.hx, self.outputSize, bidirectional=True),
50+
nn.Linear(self.inputSize, self.hx),
51+
nn.ReLU(),
52+
nn.Linear(self.hx, self.outputSize),
53+
nn.ReLU(),
54+
nn.Linear(self.hx, self.outputSize),
55+
nn.ReLU(),
56+
nn.Linear(self.hx, self.outputSize),
57+
nn.ReLU(),
58+
nn.Linear(self.hx, self.outputSize),
59+
nn.Sigmoid()
60+
)
61+
62+
return net
63+
64+
class HuggingFace:
65+
def __init__(self, modelName: str = "google/gemma-3-270m", device: str = "cpu", type: str = "text-generation"):
66+
self.modelName = modelName
67+
self.device = device
68+
self.type = type
69+
70+
def model(self, data):
71+
from transformers import pipeline
72+
pipe = pipeline(self.type, self.modelName, device=self.device)(data)
73+
return pipe
2.23 KB
Binary file not shown.
761 Bytes
Binary file not shown.
1.25 KB
Binary file not shown.

Algorthmic_Tests/gobalAlgTest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from Algorthmic_Tests import primeCounter
22
from Algorthmic_Tests import waveFunction
3-
from Algorthmic_Tests import rnnAlgorithm
43
import time
54

65

Algorthmic_Tests/rnnAlgorithm.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
3.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)