xcx0902 commited on
Commit
893cb78
·
verified ·
1 Parent(s): dbe2aee

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. model.safetensors +2 -2
  2. run.py +2 -2
  3. test.py +6 -5
  4. to_safetensors.py +2 -1
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:99a3bb67679f9a5ee8ea27df6fed196e33d35fb20bf73ca7192a03f0ff16017c
3
- size 10513028
 
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().cpu().numpy()
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
- lacc.append(acc)
16
- pbar.set_description_str(f"Round {r}, Average Accuracy = {sum(lacc) / len(lacc) * 100}%")
17
- print(f"Final Accuracy: {sum(lacc) / len(lacc) * 100}%")
 
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
- save_file(model.state_dict(), "model.safetensors")
 
 
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)