How to add sparsity between layers?

How to add sparsity between layers?

Sorry, you might need to be a bit more specific as to what you are trying to do

I’m trying to convert following to pytorch:

autoenc1 = trainAutoencoder(xTrainImages,hiddenSize1, …
‘MaxEpochs’,400, …
‘L2WeightRegularization’,0.004, …
‘SparsityRegularization’,4, …
‘SparsityProportion’,0.15, …
‘ScaleData’, false);