File size: 925 Bytes
021e065
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os

BASE_DIR = r"c:\Users\LENOVO\Desktop\senti_ai"
PACKS = ["sentibiz", "senticorporate", "sentiglobal", "sentiplan"]

for pack in PACKS:
    model_path = os.path.join(BASE_DIR, pack, "model.py")
    if not os.path.exists(model_path):
        print(f"Skipping {pack} (not found)")
        continue
        
    with open(model_path, "r", encoding="utf-8") as f:
        content = f.read()
        
    old_tensor_line = "x = torch.tensor([feat], dtype=torch.float32)"
    new_tensor_line = "x = torch.tensor([feat[:9]], dtype=torch.float32)"
    
    if old_tensor_line in content:
        print(f"Fixing {pack} model tensor shape...")
        content = content.replace(old_tensor_line, new_tensor_line)
        with open(model_path, "w", encoding="utf-8") as f:
            f.write(content)
    else:
        print(f"{pack} does not have target tensor line or is already fixed")

print("Finished fixing dimensions.")