In this paper, the spectra of electron beams produced in vacuum and gas diodes were analyzed to study the capabilities and limitations of their reconstruction from beam attenuation in foils of different thickness. The electron energy distributions were calculated using the Tikhonov regularization for Fredholm integral equations on minimum a priori assumptions. The spectra reconstructed in the study were those of electron beams, including a supershort avalanche electron beam, produced in experiments on a DUET plasma-cathode electron accelerator and SLEP-150M accelerator.