Alternatively, two types of sputtering targets are used in forming the film of the tunnel barrier layer, and a ratio of a power supplied to one target to a power supplied to the other target is changed with an elapse of time, so that a composition distribution is generated in the tunnel barrier layer.