Upload folder using huggingface_hub
Browse files- model.safetensors +2 -2
- run.py +2 -2
- test.py +6 -5
- to_safetensors.py +2 -1
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce76036027b269298c15c154ddf683fa4092e9f9c3911c280ef291498da7c46c
|
| 3 |
+
size 10513084
|
run.py
CHANGED
|
@@ -6,8 +6,8 @@ model = torch.load("model.pth", weights_only=False).to(device)
|
|
| 6 |
def run(test):
|
| 7 |
with torch.no_grad():
|
| 8 |
test_data = torch.tensor([test], dtype=torch.float).to(device)
|
| 9 |
-
predictions = model(test_data)
|
| 10 |
-
return predictions.squeeze().
|
| 11 |
|
| 12 |
if __name__ == '__main__':
|
| 13 |
x, y = map(int, input().split())
|
|
|
|
| 6 |
def run(test):
|
| 7 |
with torch.no_grad():
|
| 8 |
test_data = torch.tensor([test], dtype=torch.float).to(device)
|
| 9 |
+
predictions: torch.Tensor = model(test_data)
|
| 10 |
+
return predictions.squeeze().item()
|
| 11 |
|
| 12 |
if __name__ == '__main__':
|
| 13 |
x, y = map(int, input().split())
|
test.py
CHANGED
|
@@ -2,9 +2,9 @@ from run import run
|
|
| 2 |
from tqdm import trange
|
| 3 |
import random
|
| 4 |
|
| 5 |
-
lacc = []
|
| 6 |
-
|
| 7 |
def test(round):
|
|
|
|
|
|
|
| 8 |
pbar = trange(round)
|
| 9 |
for r in pbar:
|
| 10 |
x = random.randint(1, 100)
|
|
@@ -12,9 +12,10 @@ def test(round):
|
|
| 12 |
pans = run([x, y])
|
| 13 |
tans = x * y
|
| 14 |
acc = 1 - abs(tans - pans) / tans
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
if __name__ == '__main__':
|
| 20 |
test(100000)
|
|
|
|
| 2 |
from tqdm import trange
|
| 3 |
import random
|
| 4 |
|
|
|
|
|
|
|
| 5 |
def test(round):
|
| 6 |
+
sumacc = 0
|
| 7 |
+
lenacc = 0
|
| 8 |
pbar = trange(round)
|
| 9 |
for r in pbar:
|
| 10 |
x = random.randint(1, 100)
|
|
|
|
| 12 |
pans = run([x, y])
|
| 13 |
tans = x * y
|
| 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__':
|
| 21 |
test(100000)
|
to_safetensors.py
CHANGED
|
@@ -2,4 +2,5 @@ import torch
|
|
| 2 |
from safetensors.torch import save_file
|
| 3 |
|
| 4 |
model = torch.load("model.pth", weights_only=False)
|
| 5 |
-
|
|
|
|
|
|
| 2 |
from safetensors.torch import save_file
|
| 3 |
|
| 4 |
model = torch.load("model.pth", weights_only=False)
|
| 5 |
+
metadata = {"author": "xcx0902", "year": "2025"}
|
| 6 |
+
save_file(model.state_dict(), "model.safetensors", metadata=metadata)
|