mlx.core.savez#

savez(file: object, *args, **kwargs) None#

Save several arrays to a binary file in uncompressed .npz format.

import mlx.core as mx

x = mx.ones((10, 10))
mx.savez("my_path.npz", x=x)

import mlx.nn as nn
from mlx.utils import tree_flatten

model = nn.TransformerEncoder(6, 128, 4)
flat_params = tree_flatten(model.parameters())
mx.savez("model.npz", **dict(flat_params))
Parameters:
  • file (file, str) – Path to file to which the arrays are saved.

  • args (arrays) – Arrays to be saved.

  • kwargs (arrays) – Arrays to be saved. Each array will be saved with the associated keyword as the output file name.