Upload folder using huggingface_hub
Browse files
.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
device.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
-
device
|
| 4 |
-
|
| 5 |
-
if torch.cuda.is_available(): device = 'cuda'
|
| 6 |
-
elif torch.mps.is_available(): device = 'mps'
|
| 7 |
-
else: device = 'cpu'
|
| 8 |
|
| 9 |
print(f"Device set to {torch.Tensor().to(device).device}")
|
|
|
|
|
|
|
|
|
| 1 |
import torch
|
| 2 |
|
| 3 |
+
device = torch.accelerator.current_accelerator() or torch.device('cpu')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
print(f"Device set to {torch.Tensor().to(device).device}")
|
| 6 |
+
|
| 7 |
+
__all__ = ['device']
|
test.py
CHANGED
|
@@ -5,8 +5,7 @@ import random
|
|
| 5 |
def test(round):
|
| 6 |
sumacc = 0
|
| 7 |
lenacc = 0
|
| 8 |
-
pbar
|
| 9 |
-
for r in pbar:
|
| 10 |
x = random.randint(1, 100)
|
| 11 |
y = random.randint(1, 100)
|
| 12 |
pans = run([x, y])
|
|
@@ -14,7 +13,7 @@ def test(round):
|
|
| 14 |
acc = 1 - abs(tans - pans) / tans
|
| 15 |
sumacc += acc
|
| 16 |
lenacc += 1
|
| 17 |
-
pbar.set_description_str(f"Round {r}, Average Accuracy = {sumacc / lenacc * 100}%")
|
| 18 |
print(f"Final Accuracy: {sumacc / lenacc * 100}%")
|
| 19 |
|
| 20 |
if __name__ == '__main__':
|
|
|
|
| 5 |
def test(round):
|
| 6 |
sumacc = 0
|
| 7 |
lenacc = 0
|
| 8 |
+
for r in (pbar := trange(round)):
|
|
|
|
| 9 |
x = random.randint(1, 100)
|
| 10 |
y = random.randint(1, 100)
|
| 11 |
pans = run([x, y])
|
|
|
|
| 13 |
acc = 1 - abs(tans - pans) / tans
|
| 14 |
sumacc += acc
|
| 15 |
lenacc += 1
|
| 16 |
+
pbar.set_description_str(f"Round {r}, Average Accuracy = {sumacc / lenacc * 100 : .6f}%")
|
| 17 |
print(f"Final Accuracy: {sumacc / lenacc * 100}%")
|
| 18 |
|
| 19 |
if __name__ == '__main__':
|