Consider using a hybrid approach that switches between minibatch stochastic gradient descent and batch gradient descent based on the dataset’s redundancy level. This would adaptively adjust the computational cost and ensure efficient processing even when all m samples are identical.