Stochastic learning of fractal images