The atomic and electronic structure of nonstoichiometric amorphous tantalum oxide (TaOx) films of different composition has been investigated by means of electron microscopy, x-ray photoelectron spectroscopy, Raman and infrared spectroscopy. The dispersion of the absorption coefficient and refraction index has been studied by spectral ellipsometry. The optical spectra were interpreted using the results of a quantum-chemical simulation for crystalline orthorhombic TaOx. It was found that the presence of oxygen vacancies in the oxygen-deficient TaOx film show an optical absorption peak at 4.6 eV. It has been established that TaOx consists of stoichiometric Ta2O5, metallic Ta clusters less than 20 nm in size, and tantalum suboxides TaOy (y < 2.5). The model of nanoscale potential fluctuations of TaOx bandgap in the range of 0-4.2 eV is proposed and justified. The design of the flash memory element based on the effect of localization of electrons and holes in Ta metallic nanoclusters in the TaOx matrix is proposed.