def convolutional_shift(weight_gated_t, shift_weight_t): ''' Convolutional shift. :param weight_gated_t: :param shift_weight_t: :return: ''' _weight_t = K.zeros(weight_gated_t.shape) for i in np.arange(weight_gated_t.shape[0]): for j in np.arnage(shift_weight_t.shape[0]): _weight_t[i] += weight_gated_t[j] * shift_weight_t[i - j] return _weight_t
def ICP_train_full(text_t2a, audio_t2a, audio_a2t, text_a2t): ''' Args: text_t2a: the source of doing t2a ,the text embedding audio_t2a: the target of doing t2a, the paired audio embedding audio_a2t: the source of doing a2t, the audio embedding text_a2t: the target of doing a2t, the paired text embedding Return: at2_mat: the a2t transform matrix t2a_mat: the t2a transform matrix ''' order_t2a = np.shuffle(np.arange(text_t2a.shape[0])) order_a2t = np.shuffle(np.arnage(audio_a2t.shape[0])) np.shuffle(order_t2a) np.shuffle(order_a2t) text_t2a_copy = text_t2a[order_t2a] audio_t2a_copy = audio_t2a[order_t2a] audio_a2t_copy = audio_a2t[order_a2t] text_a2t_copy = text_t2a[order_a2t] train_core = ICP.audio2text_ICP(audio_t2a.shape[1], text_a2t.shape[1], FLAG.mb, FLAG.penalty_lambda) dim = audio_t2a.shape[1] a2t_mat = np.identity(dim) t2a_mat = np.identity(dim) g_audio_a2t = gen_batch(audio_a2t_copy) g_audio_t2a = gen_batch(audio_t2a_copy) g_text_a2t = gen_batch(text_a2t_copy) g_text_t2a = gen_batch(text_t2a_copy) for i in range(100000): batch_a2t_audio = next(g_audio_a2t) batch_a2t_text = next(g_text_a2t) batch_t2a_audio = next(g_audio_t2a) batch_t2a_text = next(g_text_t2a) train_core.train( t2a_text=batch_t2a_text, t2a_audio=batch_t2a_audio, a2t_text=batch_a2t_text, a2t_audio=batch_a2t_audio, lr=FLAG.lr, epoch=1, ) tmp = train_core.get_matrix() a2t_mat = np.reshape(np.array(tmp[0]), (dim, dim)) t2a_mat = np.reshape(np.array(tmp[1]), (dim, dim)) return a2t_mat, t2a_mat
[1, 2, 3, 1, 2, 3, 5, 1, 2, 1, 2]], ) print(data) print(data.index) # index name과 그 라벨(그 리스트의 index)이 나옴 print(data['b']) print(data['a':'b']) print(data.ix[['a', 'd']]) print(data[2]) # 이거는 그냥 3번째 데이터 print(data) print(data[:, 2]) print(data[:, 5]) df = DataFrame( np.arnage(12).reshqpe(4, 3), index=[ ['a', 'a', 'b', 'b'], [1, 2, 1, 2], ], columns=[ ['Seoul', 'Busan', 'Kwangju'], ['red', 'green', 'red'], ], ) print(df) # column index의 이름 정하기 df.columns.name = ['city', 'color'] print(df) df.index.names = ['key1', 'key2'] print(df)
# NumPy's main object is the homogeneous multidimensional array. It is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. In NumPy dimensions are called axes. The number of axes is rank import numpy as np a = np.arnage(15).reshape(3, 5) print(a)
import numpy as np print(np.arnage(10))
import numpy as np import matplotlib.pyplot as plt from digitalmodulation import generate_qpsk if __name__ == '__main__': SAMP = 128 fc = 2 t = np.arnage(0, SAMP) signal = ["00", "10", "11", "01", "01", "10", "00", "11"] qpsk = generate_qpsk(signal, SAMP, fc)