We study how to optimally schedule production in technologies following experience curves under uncertainty to meet a known demand schedule. Experience effects encourage specialization but in an uncertain world a risk-averse decision maker may prefer to diversify. This is highly relevant for planning investment strategies for the transition to a sustainable energy system. We develop a stochastic model and characterize the optimal degree of diversification as a function of relative progress rates, initial conditions, time horizon, discount rate and variability. Due to feedback effects from learning, solutions often depend sensitively on underlying model parameters, and we observe instantaneous switching between local optimums of the objective function. This differs sharply from portfolios of standard financial assets. Technological lock-in may be characterised in this framework. When the planning horizon is long, we find that it is optimal to specialize more in the short term than the long term, where uncertainty dominates the utility function.