Skip to content

Commit

Permalink
Merge pull request #245 from Pushover-1/main
Browse files Browse the repository at this point in the history
AI IS HERE GUYSSS!!!
  • Loading branch information
mawerty authored Jan 19, 2024
2 parents cb18ec2 + 2fff8d8 commit b256645
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ A: Thecoderunsfasterwhentherearenouselessspacesandnewlines.
- Processing
- Prolog
- Python
- Python AI/ML/DL
- q
- Q#
- R
Expand Down
33 changes: 33 additions & 0 deletions implementations/main_ml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import torch
import torch.nn as nn

class Prime(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(1,1)
self.linear.apply(self.init_weights_biases)

def init_weights_biases(self,m):
if isinstance(m, nn.Linear):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias,0)

def forward(self, number):
out = self.linear(number)
out = nn.functional.relu(out)
return out

def is_prime(number):
if number<=0:
raise ValueError("Don't you even know the definition of Prime Numbers, doofus!!")
is_prime_model = Prime()
input_tensor = torch.tensor([float(number)])
output = is_prime_model(input_tensor)
if output:
return False

if __name__ == "__main__":
is_prime(1)



33 changes: 33 additions & 0 deletions optimized_implementations/main_ml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import torch
import torch.nn as nn

class Prime(nn.Module):
def __init__(self):
super().__init__()
self.linear = nn.Linear(1,1)
self.linear.apply(self.init_weights_biases)

def init_weights_biases(self,m):
if isinstance(m, nn.Linear):
nn.init.constant_(m.weight, 1)
nn.init.constant_(m.bias,0)

def forward(self, number):
out = self.linear(number)
out = nn.functional.relu(out)
return out

def is_prime(number):
if number<=0:
raise ValueError("Don't you even know the definition of Prime Numbers, doofus!!")
is_prime_model = Prime()
input_tensor = torch.tensor([float(number)])
output = is_prime_model(input_tensor)
if output:
return False

if __name__ == "__main__":
is_prime(1)



0 comments on commit b256645

Please sign in to comment.