OpenMined / KotlinSyft

The official Syft worker for secure on-device machine learning
https://www.openmined.org
Apache License 2.0
85 stars 28 forks source link

Accurate method to determine the model size #302

Open mustansarsaeed opened 3 years ago

mustansarsaeed commented 3 years ago

Hi, I am using syft 0.2.x. I want to determine the size of the model. What is the correct way to determine the size? I have two options:

Option: 1

val modelFile = File(modelFileLocation)
modelFile.length()

Option 2

SyftState.loadSyftState(modelFile)
size of syftstate

In terms of model size and number of parameters, SyftState should be used or modelFile.length()?

Thanks.

vkkhare commented 3 years ago

@mustansarsaeed number of parameters can be calculated from model

val num_params = model.getParamArray().reduce{ sum, tensor ->
    sum + tensor.shape().reduce{ m,e -> m*e }
}