-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from Pushover-1/main
AI IS HERE GUYSSS!!!
- Loading branch information
Showing
3 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|