src/transformers/models/marian/modeling_tf_marian.py
def _init_weight(n_pos: int, dim: int):
        """
        Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
        the 2nd half of the vector. [dim // 2:]
        """
        position_enc = np.array(
            [[pos / np.power(10000, 2 * (j // 2) / dim) for j in range(dim)] for pos in range(n_pos)]
        )
        # index 0 is all zero
        position_enc[:, 0 : dim // 2] = np.sin(position_enc[:, 0::2])
        position_enc[:, dim // 2 :] = np.cos(position_enc[:, 1::2])
        # convert to tensor
        table = tf.convert_to_tensor(position_enc)
        tf.stop_gradient(table)
        return table

        Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
        the 2nd half of the vector. [dim // 2:]
        
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
the 2nd half of the vector.
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved . The cos features are in the 2nd half of the vector .
def _init_weight(n_pos: int, dim: int):
        position_enc = np.array(
            [[pos / np.power(10000, 2 * (j // 2) / dim) for j in range(dim)] for pos in range(n_pos)]
        )
        position_enc[:, 0 : dim // 2] = np.sin(position_enc[:, 0::2])
        position_enc[:, dim // 2 :] = np.cos(position_enc[:, 1::2])
        table = tf.convert_to_tensor(position_enc)
        tf.stop_gradient(table)
        return table
def _init_weight ( n_pos : int , dim : int ) : position_enc = np . array ( [ [ pos / np . power ( 10000 , 2 * ( j // 2 ) / dim ) for j in range ( dim ) ] for pos in range ( n_pos ) ] ) position_enc [ : , 0 : dim // 2 ] = np . sin ( position_enc [ : , 0 : : 2 ] ) position_enc [ : , dim // 2 : ] = np . cos ( position_enc [ : , 1 : : 2 ] ) table = tf . convert_to_tensor ( position_enc ) tf . stop_gradient ( table ) return table
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved.
Identical to the XLM create_sinusoidal_embeddings except features are not interleaved .
"""
        Identical to the XLM create_sinusoidal_embeddings except features are not interleaved. The cos features are in
        the 2nd half of the vector. [dim // 2:]
        """ # index 0 is all zero # convert to tensor
n_pos
int
dim
int