Uvindu Bimsara
Uvindu Bimsara

Reputation: 1

Neural Network Model Weight Matrix

I was trying to make the all values in my trained neural network model to zero's.
The initial model file size nearly 330 MB. But when I modified the values of weight matrix to zero's it becomes double size model. nearly 660MB.

What could be the reason for this. I check with the weight matrix shape. it doesn't changed. same for both

model_transmitter_main0 = keras.models.load_model(f"/content/drive/MyDrive/auto_encoder/models/video{the_video}/gop{the_gop}/model_transmitter_main0.h5") 

weights1 = model_transmitter_main0.get_weights() 

weights1[0] = np.zeros_like(weights1[0]) 

weights1[1] = np.zeros_like(weights1[1]) 

weights1[2] = np.zeros_like(weights1[2]) 

weights1[3] = np.zeros_like(weights1[3]) 

model_transmitter_main0.set_weights(weights1) 

# Save the modified model 

model_transmitter_main0.save("/content/drive/MyDrive/auto_encoder/existing.h5")

Upvotes: 0

Views: 53

Answers (1)

king juno
king juno

Reputation: 21

It must probably change of dtype. An example would be initially it was tf.float32 and when you initialised it to zero, it became tf.float64. You can check whether or not if the dtype of model changed.

Upvotes: 0

Related Questions