I’m wondering what’s the Tensorflow way of storing and performing Tensor manipulation (i.e. Tensor multiplication, apply_gradient) of trainable weights in a custom layer that could potentially be sparse based on user specification. I’ve looked into

  
      

      TensorFlow
  

  
    

tf.boolean_mask  |  TensorFlow Core v2.5.0

  Apply boolean mask to tensor.


  

  
    
    
  

  


and

  
      

      TensorFlow
  

  
    

tf.RaggedTensor  |  TensorFlow Core v2.5.0

  Represents a ragged tensor.


  

  
    
    
  

  


but I’m not sure if it’s possible to apply these as ways to store and update trainable weights.