3333import time
3434from dataclasses import dataclass , field
3535from pathlib import Path
36- from typing import Dict , List , Optional , Tuple
36+ from typing import Any , Dict , List , Optional , Tuple
3737
3838import numpy as np
3939import torch
@@ -126,7 +126,7 @@ def __init__(
126126 ):
127127 super ().__init__ ()
128128
129- layers = []
129+ layers : List [ nn . Module ] = []
130130 prev_dim = input_dim
131131
132132 # First layer: input -> first hidden
@@ -477,13 +477,13 @@ def generate_training_data(
477477 Returns:
478478 Tuple of (inputs_dict, targets_array)
479479 """
480- X : Dict [str , List [ float ] ] = {
480+ X : Dict [str , Any ] = {
481481 "time" : [],
482482 "t_outdoor" : [],
483483 "q_solar" : [],
484484 "q_internal" : [],
485485 }
486- y = []
486+ y : List [ float ] = []
487487
488488 for _ in range (n_samples ):
489489 # Generate outdoor temperature profile (daily cycle with noise)
@@ -521,11 +521,12 @@ def generate_training_data(
521521 y .extend (t_indoor )
522522
523523 # Convert to arrays
524+ X_array : Dict [str , np .ndarray ] = {}
524525 for key in X :
525- X [key ] = np .array (X [key ], dtype = np .float32 )
526- y = np .array (y , dtype = np .float32 ).reshape (- 1 , 1 )
526+ X_array [key ] = np .array (X [key ], dtype = np .float32 )
527+ y_array = np .array (y , dtype = np .float32 ).reshape (- 1 , 1 )
527528
528- return X , y
529+ return X_array , y_array
529530
530531 def generate_collocation_points (
531532 self ,
@@ -800,8 +801,8 @@ def export_onnx(
800801 model .eval ()
801802 torch .onnx .export (
802803 model ,
803- sample_input ,
804- output_path ,
804+ ( sample_input ,) ,
805+ str ( output_path ) ,
805806 input_names = ["input" ],
806807 output_names = ["t_indoor" ],
807808 dynamic_axes = {
@@ -810,6 +811,7 @@ def export_onnx(
810811 },
811812 opset_version = 17 ,
812813 )
814+
813815 logger .info ("ONNX export successful" )
814816
815817
0 commit comments