This paper studies a new application of deep learning (DL) for optimizing constellations in two-way relaying with physical-layer network coding (PNC), where deep neural network (DNN)-based modulation and demodulation are employed at each terminal and relay node. We train DNNs such that the cross entropy loss is directly minimized, and thus it maximizes the likelihood, rather than considering the Euclidean distance of the constellations. The proposed scheme can be extended to higher level constellations with slight modification of the DNN structure. Simulation results demonstrate a significant performance gain in terms of the achievable sum rate over conventional relaying schemes. Furthermore, since our DNN demodulator directly outputs bit-wise probabilities, it is straightforward to concatenate with soft-decision channel decoding.