adalca / neurite

Neural networks toolbox focused on medical image analysis
Apache License 2.0
335 stars 67 forks source link

Optimized functions to handle large arrays #64

Open ajinkya-kulkarni opened 1 year ago

ajinkya-kulkarni commented 1 year ago
  1. Used a numerically stable implementation to compute the softmax of a numpy array along a given dimension, which reduces the chances of overflows or underflows and improves performance for large arrays.
  2. Used numpy's unique() and cumsum() functions to create the lab_to_ind lookup table, which is more efficient than looping over each label, especially for large arrays.
  3. Used numpy's in1d() function to create a boolean mask of the unique labels, and then used numpy's broadcasting to assign the corresponding RGB values to the output array, which is more efficient than looping over each label, especially for large arrays.