changed opts.n to opts.numepochs