-
Notifications
You must be signed in to change notification settings - Fork 3
Calculators
This function calculates the number of layers of which a passed model is comprised. Users can select whether to calculate all layers or just the model's hidden layers by specifying whether to include I/O layers via the include_io
parameter.
import nexport
num_layers = nexport.calculate_layers(model=model,
include_io=True
)
Argument | Data type | Default | Description |
---|---|---|---|
model |
object | Instantiated PyTorch or TensorFlow model | |
include_io |
boolean | True |
Whether to include input & output layer in calculation |
Argument | Required | Accepted values |
---|---|---|
model |
✅ | Any fully-connected PyTorch or TensorFlow model |
include_io |
❌ |
True , False
|
This is whether to calculate the neurons which make up the input & output layers of the passed model.
This function returns an integer
representing the number of layers found in the passed model.
This function does not have any side-effects.
This function calculates the number of total neurons in a passed model. Users can select whether to count all neurons or just those present in the model's hidden layers by specifying whether to include I/O layers via the include_io
parameter.
num_neurons = nexport.calculate_neurons(model=model,
include_io=True
)
Argument | Data type | Default | Description |
---|---|---|---|
model |
object | Instantiated PyTorch or TensorFlow model | |
include_io |
boolean | True |
Whether to include input & output layer in calculation |
Argument | Required | Accepted values |
---|---|---|
model |
✅ | Any fully-connected PyTorch or TensorFlow model |
include_io |
❌ |
True , False
|
This is whether to calculate the neurons which make up the input & output layers of the passed model.
This function returns an integer
representing the number of neurons calculated in the passed model.
This function does not have any side-effects.
This function computes the number of trainable parameters of a passed model. Users are able to specify which types of parameters should be returned via the param_type
parameter.
num_params = nexport.calculate_params(model=model,
param_types="wbt"
)
Argument | Data type | Default | Description |
---|---|---|---|
model |
object | Instantiated PyTorch or TensorFlow model | |
param_types |
string | wbt |
Type of parameters to be computed and returned |
Argument | Required | Accepted values |
---|---|---|
model |
✅ | Any fully-connected PyTorch or TensorFlow model |
param_types |
❌ | Any combination of w , b , and t
|
This is which parameters to include in what is returned by the computation function. The user can specify any combination of w
, b
, and t
, where each respectively represents:
-
w
: The neuron weight parameters of the passed model. -
b
: The neuron bias parameters of the passed model. -
t
: The total parameters of the passed model.
This function returns a list
of parameter counts respective to the configuration passed to param_types
.
This function does not have any side-effects.
Created and maintained by Jordan Welsman @ LBNL.
nexport
Copyright (c) 2022-2023, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy).
All rights reserved.