Maninder Singh
commited on
Commit
·
ac48d25
1
Parent(s):
d17eb4a
Inference Code added
Browse files
README.md
CHANGED
|
@@ -50,10 +50,13 @@ Model is trained for 25 epochs on Azure for nearly 26000 Datapoints for above Me
|
|
| 50 |
|
| 51 |
## Below is the Training Result for 25 epochs.
|
| 52 |
<ul>
|
| 53 |
-
<li>Training Computer Configuration:
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
<li>Training Time taken: exactly 7 hours for 25 epochs</li>
|
| 58 |
<li>Training Hyper-parameters: </li>
|
| 59 |
</ul>
|
|
@@ -64,4 +67,41 @@ Model is trained for 25 epochs on Azure for nearly 26000 Datapoints for above Me
|
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
-

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
## Below is the Training Result for 25 epochs.
|
| 52 |
<ul>
|
| 53 |
+
<li>Training Computer Configuration: <ul>
|
| 54 |
+
<li>GPU:1xNvidia Tesla T4, </li>
|
| 55 |
+
<li>VRam: 16GB,</li>
|
| 56 |
+
<li>Ram:112GB,</li>
|
| 57 |
+
<li>Cores:6 Cores </li>
|
| 58 |
+
</ul></li>
|
| 59 |
+
|
| 60 |
<li>Training Time taken: exactly 7 hours for 25 epochs</li>
|
| 61 |
<li>Training Hyper-parameters: </li>
|
| 62 |
</ul>
|
|
|
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
+

|
| 71 |
+
|
| 72 |
+
## Inference Code
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
import torch
|
| 76 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, TextClassificationPipeline
|
| 77 |
+
model_name = 'Maninder120996/programming-language-identification'
|
| 78 |
+
loaded_tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 79 |
+
loaded_model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 83 |
+
text = """
|
| 84 |
+
PROGRAM Triangle
|
| 85 |
+
IMPLICIT NONE
|
| 86 |
+
REAL :: a, b, c, Area
|
| 87 |
+
PRINT *, 'Welcome, please enter the&
|
| 88 |
+
&lengths of the 3 sides.'
|
| 89 |
+
READ *, a, b, c
|
| 90 |
+
PRINT *, 'Triangle''s area: ', Area(a,b,c)
|
| 91 |
+
END PROGRAM Triangle
|
| 92 |
+
FUNCTION Area(x,y,z)
|
| 93 |
+
IMPLICIT NONE
|
| 94 |
+
REAL :: Area ! function type
|
| 95 |
+
REAL, INTENT( IN ) :: x, y, z
|
| 96 |
+
REAL :: theta, height
|
| 97 |
+
theta = ACOS((x**2+y**2-z**2)/(2.0*x*y))
|
| 98 |
+
height = x*SIN(theta); Area = 0.5*y*height
|
| 99 |
+
END FUNCTION Area
|
| 100 |
+
|
| 101 |
+
"""
|
| 102 |
+
inputs = loaded_tokenizer(text, return_tensors="pt",truncation=True)
|
| 103 |
+
with torch.no_grad():
|
| 104 |
+
logits = loaded_model(**inputs).logits
|
| 105 |
+
predicted_class_id = logits.argmax().item()
|
| 106 |
+
loaded_model.config.id2label[predicted_class_id]
|
| 107 |
+
```
|