Reputation: 143
I have an intermediate model that outputs symmetric arrays. Those arrays are then used as input to another model. I'd like to just flatten the arrays and discard the lower triangles, since they're symmetric. Is there a best/most efficient way to do this?
Edit: I want the triangle extraction to be handled similar to any other Keras layer, so that the output of the first model can be input directly to the second model and trained end-to-end.
Upvotes: 4
Views: 1259
Reputation: 7131
Tensorflow and Keras use Numpy to handle the data. Consider using Numpy functions triu or triu_indices
Upvotes: 2