Skip to content

model_tools

pytorch_symbolic.model_tools

get_parameter_count

get_parameter_count(model: nn.Module, only_trainable = False)

Get the number of parameters of a model.

get_parameter_shapes

get_parameter_shapes(model: nn.Module)

Get the shapes of parameters of a model.

model_similar

model_similar(a: nn.Module, b: nn.Module)

Check whether two models have the same number of parameters and the same shapes of parameters.

hash_torch_tensor

hash_torch_tensor(tensor: torch.Tensor)

Interpret the tensor as a string and return its hash.

models_have_corresponding_parameters

models_have_corresponding_parameters(a: nn.Module, b: nn.Module)

Check whether two models' parameters have identical hash values.

Parameter order does not matter. So if two models have identical parameters but in different order, this will still return True.