Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tutorials/v1/device/08_initialize_nnx_on_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def init_model_logic(input_dim: int, hidden_dim: int, output_dim: int, seed: int
)

# Split and convert state to pure dict
_graphdef, state = nnx.split(model)
_, state = nnx.split(model)
state_dict = state.to_pure_dict()

print(f"[Device P0] Initialized model with {len(state_dict)} parameter groups")
Expand Down Expand Up @@ -180,7 +180,7 @@ def init_model_with_optimizer_logic(
)

# Split and convert model state to pure dict
_graphdef, state = nnx.split(model)
_, state = nnx.split(model)
model_state_dict = state.to_pure_dict()

# Initialize optimizer and convert its state to pure dict
Expand Down
6 changes: 3 additions & 3 deletions tutorials/v1/device/09_split_learning_vertical.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,14 +646,14 @@ def initialize_and_train_split_learning(

def _init_alice_base():
model = AliceBaseModel(input_dim=m1, hidden_dim=h1, rngs=nnx.Rngs(seed_alice))
_graphdef, state = nnx.split(model)
_, state = nnx.split(model)
tx = optax.sgd(learning_rate)
opt_state = tx.init(state.to_pure_dict())
return model_state_to_dict(state, opt_state, 0)

def _init_bob_base():
model = BobBaseModel(input_dim=m2, hidden_dim=h2, rngs=nnx.Rngs(seed_bob))
_graphdef, state = nnx.split(model)
_, state = nnx.split(model)
tx = optax.sgd(learning_rate)
opt_state = tx.init(state.to_pure_dict())
return model_state_to_dict(state, opt_state, 0)
Expand All @@ -665,7 +665,7 @@ def _init_alice_agg():
output_dim=n_classes,
rngs=nnx.Rngs(seed_agg),
)
_graphdef, state = nnx.split(model)
_, state = nnx.split(model)
tx = optax.sgd(learning_rate)
opt_state = tx.init(state.to_pure_dict())
return model_state_to_dict(state, opt_state, 0)
Expand Down