Low-rank surrogate modeling and stochastic zero-order optimization for training of neural networks with black-box layers