Demonstration of Lossy Linear Transformations and Two-Photon Interference on a Photonic Chip