From de654af9d36755516cc70e8ac94456e14aeb3518 Mon Sep 17 00:00:00 2001 From: Binod Singh Date: Thu, 18 Jan 2024 18:42:55 +0100 Subject: [PATCH 1/3] Add python deep learning method --- optimized_implementations/main_ml.py | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 optimized_implementations/main_ml.py diff --git a/optimized_implementations/main_ml.py b/optimized_implementations/main_ml.py new file mode 100644 index 0000000..aa7fc17 --- /dev/null +++ b/optimized_implementations/main_ml.py @@ -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) + + + From e17f9185c2468197127efd36bef44dae8b16238e Mon Sep 17 00:00:00 2001 From: Binod Singh Date: Thu, 18 Jan 2024 18:48:57 +0100 Subject: [PATCH 2/3] Add AI/ML/DL implementation in python --- README.md | 1 + implementations/main_ml.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 implementations/main_ml.py diff --git a/README.md b/README.md index a3743ff..c924015 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,7 @@ A: Thecoderunsfasterwhentherearenouselessspacesandnewlines. - Processing - Prolog - Python +- Python Machine Learning - q - Q# - R diff --git a/implementations/main_ml.py b/implementations/main_ml.py new file mode 100644 index 0000000..aa7fc17 --- /dev/null +++ b/implementations/main_ml.py @@ -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) + + + From 2fff8d83cee011a53f0347a00c008f150d7de859 Mon Sep 17 00:00:00 2001 From: Pushover-1 <114254993+Pushover-1@users.noreply.github.com> Date: Thu, 18 Jan 2024 18:49:53 +0100 Subject: [PATCH 3/3] Update README.md with AI/ML/DL --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c924015..ece1a9f 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ A: Thecoderunsfasterwhentherearenouselessspacesandnewlines. - Processing - Prolog - Python -- Python Machine Learning +- Python AI/ML/DL - q - Q# - R