Skip to content

Commit 3c81d49

Browse files
committed
refactor: remove legacy pickle save_model/load_model, use save/load
1 parent 4f3c095 commit 3c81d49

1 file changed

Lines changed: 0 additions & 17 deletions

File tree

nnlib/neural_network.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import json
2424
import logging
2525
import os
26-
import pickle
2726
import time
2827
from typing import Any, Dict, List, Optional, Tuple, Union
2928

@@ -507,22 +506,6 @@ def load(cls, directory: str) -> "NeuralNetwork":
507506
model.load_weights(os.path.join(directory, "weights.npz"))
508507
return model
509508

510-
# Legacy pickle API (kept for compatibility, not recommended)
511-
def save_model(self, filepath: str) -> None:
512-
"""Legacy serialization via pickle. Prefer `save(directory)`."""
513-
logger.warning(
514-
"save_model() uses pickle and is fragile. Use save('dir/') for "
515-
"portable persistence (JSON + NPZ)."
516-
)
517-
with open(filepath, "wb") as f:
518-
pickle.dump(self, f)
519-
520-
@staticmethod
521-
def load_model(filepath: str) -> "NeuralNetwork":
522-
"""Legacy: loads a model from a pickle file. Prefer `load()`."""
523-
with open(filepath, "rb") as f:
524-
return pickle.load(f)
525-
526509
# Alias for backward compatibility
527510
def get_weights(self) -> List[np.ndarray]:
528511
"""Flat list of trainable parameters (same order as set_weights)."""

0 commit comments

Comments
 (0)