The XOR network code is widely used in the conventional network coding. However, when the channel is noisy, the XOR code is suboptimal in terms of minimizing distortion in the source signal. We propose to use a new network code for the two-way relay channel, designed to minimize signal distortion due to the channel noise. We assume the source signal X is encoded by a source encoder and the sequence of symbols is transmitted over the two-way relay channel with noise. The received sequence of symbols may be corrupted by the channel noise, and X̂, the estimation of X, may be different from X. We design a new network code which minimizes the distortion between X and X̂. To provide an algorithm to obtain a network code with minimum distortion, we define the expected distortion associated with a network code. Starting with the XOR network code, we iteratively optimize the network code to obtain smaller expected distortion, while maintaining the Latin square constraint of the network code. New network code achieves substantial performance gain over the XOR network code.