Machine Learning For Structural Characterization And Generation: Applications to Small-Angle Scattering And Electron Microscopy