Learning quantum states and unitaries of bounded gate complexity