  We introduce a novel approach to solve optimization problems on a boson
sampling device assisted by classical machine-learning techniques. By virtue of
the parity function, we map all measurement patterns, which label the basis
spanning an $M$-mode bosonic Hilbert space, to the Hilbert space of $M$ qubits.
As a result, the sampled probability function can be interpreted as a result of
sampling a multiqubit circuit. The method is presented on several instances of
a QUBO/Ising problem as well as portfolio optimization problems. Among many
demonstrated properties of the parity function is the ability to chart the
entire qubit Hilbert space no matter how shallow the initial bosonic circuits
is. In order to show this we link boson sampling circuits to a class of finite
Young's lattices (a special poset with the so-called Ferrers diagrams ordered
by inclusion), Boolean lattices and the properties of Dyck/staircase paths on
integer lattices. Our results and methods can be applied to a large variety of
photonic circuits, including the deep ones of essentially any geometry, but our
main focus is on shallow circuits as they are less affected by photon loss and
relatively easy to implement in the form of a time-bin interferometer.
