DwangoMediaVillage / keras_compressor

Model Compression CLI Tool for Keras.
https://nico-opendata.jp/ja/casestudy/model_compression/index.html
157 stars 39 forks source link

model.outputs does not changed in svd compressor #19

Open rafikg opened 5 years ago

rafikg commented 5 years ago

Hi @bachi55 https://github.com/DwangoMediaVillage/keras_compressor/blob/324ec9b463c366e01f6b40360115c50b44c1bc87/keras_compressor/compressor.py#L73

I debug the code and I see that the even the layers are swapped correctly but the model.output still have the old output not the new FactorizedDense layer

Model: "model_1"
....
....

_________________________________________________________________
dense_1 (FactorizedDense)    (None, 512)               193024    
_________________________________________________________________
batch_normalization_14 (Batc (None, 512)               2048      
_________________________________________________________________
dropout_10 (Dropout)         (None, 512)               0         
_________________________________________________________________
**dense_2 (FactorizedDense)    (None, 10)                4186**      
=================================================================
Total params: 15,001,418
Trainable params: 14,991,946
Non-trainable params: 9,472

but model.outputs still having the older dense_2 layer:

model.outputs
Out[4]: [<tf.Tensor 'dense_2/Softmax:0' shape=(?, 10) dtype=float32>]

Here the new model 
Model: new model
.......
......

dense_1 (FactorizedDense)    (None, 512)               193024    
_________________________________________________________________
batch_normalization_14 (Batc (None, 512)               2048      
_________________________________________________________________
dropout_10 (Dropout)         (None, 512)               0         
_________________________________________________________________
**dense_2 (Dense)              (None, 10)                5130**      
=================================================================
Total params: 14,931,786
Trainable params: 14,922,314
Non-trainable params: 9,472