Example #1
0
def _main():
    """
    Test model.
    """
    from pyasv.data_manage import DataManage
    from pyasv import Config
    sys.path.append("../..")

    con = Config(name='MFM',
                 n_speaker=100,
                 batch_size=64,
                 n_gpu=2,
                 max_step=5,
                 is_big_dataset=False,
                 learning_rate=0.001,
                 save_path='./save')
    x = np.random.random([6400, 50, 40, 1])
    y = np.random.randint(0, 100, [6400, 1])
    train = DataManage(x, y, con)
    enroll = train

    x = np.random.random([640, 50, 40, 1])
    y = np.random.randint(0, 100, [640, 1])
    validation = DataManage(x, y, con)
    test = validation

    run(con, train, validation)
    restore(con, enroll, test)
Example #2
0
def _main():
    """
    Test model.
    """
    from pyasv.data_manage import DataManage
    from pyasv import Config
    sys.path.append("../..")

    con = Config(name='ctdnn',
                 n_speaker=100,
                 batch_size=64 * 2,
                 n_gpu=2,
                 max_step=5,
                 is_big_dataset=False,
                 learning_rate=0.001,
                 save_path='./save')
    #con.save('ctdnn')
    x = np.random.random([6500, 9, 40, 1])
    y = np.random.randint(0, 99, [6500, 1])
    enroll = DataManage(x, y, con)
    train = enroll

    x = np.random.random([1500, 9, 40, 1])
    y = np.random.randint(0, 99, [1500, 1])
    test = DataManage(x, y, con)
    validation = test

    run(con, train, validation, False)
    restore(con, enroll, test)
def _main():
    """
    Test model.
    """
    from pyasv.data_manage import DataManage
    from pyasv import Config
    import sys
    sys.path.append("../..")
    print("Model test")
    print("input n_gpu", end="")
    a = int(eval(input()))
    con = Config(name='deepspeaker',
                 n_speaker=100,
                 batch_size=32 * max(1, a),
                 n_gpu=a,
                 max_step=5,
                 is_big_dataset=False,
                 learning_rate=0.001,
                 save_path='./save',
                 conv_weight_decay=0.01,
                 fc_weight_decay=0.01,
                 bn_epsilon=1e-3,
                 deep_speaker_out_channel=[32, 64])
    x = np.random.random([320, 100, 64, 1])
    y = np.random.randint(0, 99, [320, 1])
    train = DataManage(x, y, con)

    x = np.random.random([64, 100, 64, 1])
    y = np.random.randint(0, 99, [64, 1])
    validation = DataManage(x, y, con)

    # run(con, train, validation)
    restore(con, train, validation)
def _main():
    """
    Test model.
    """
    """
    Test model.
    """
    from pyasv.data_manage import DataManage
    from pyasv import Config
    import sys
    sys.path.append("../..")
    print("Model test")
    print("input n_gpu", end="")
    a = int(eval(input()))
    con = Config(name='deepspeaker', n_speaker=100, batch_size=32*max(1, a), n_gpu=a, max_step=2, is_big_dataset=True,
                 url_of_bigdataset_temp_file='./',
                 learning_rate=0.001, save_path='./save', conv_weight_decay=0.01, fc_weight_decay=0.01,
                 bn_epsilon=1e-3, deep_speaker_out_channel=[64, 128, 256, 512])
    x = np.random.random([320, 100, 64, 1])
    y = np.random.randint(0, 99, [320, 1])

    train = DataManage4BigData(con, 'train')
    train.write_file(x, y)

    x = np.random.random([64, 100, 64, 1])
    y = np.random.randint(0, 99, [64, 1])

    validation = DataManage4BigData(con, 'validation')
    validation.write_file(x, y)

    run(con, train, validation)

    train.clear()
    validation.clear()
def _main():
    """
    Test model.
    """
    from pyasv.data_manage import DataManage
    from pyasv import Config
    import sys
    sys.path.append("../..")
    con = Config(name='deepspeaker', n_speaker=100, batch_size=64, n_gpu=4, max_step=20, is_big_dataset=False,
                 learning_rate=0.001, save_path='./save', conv_weight_decay=0.01, fc_weight_decay=0.01, bn_epsilon=1e-3)
    x = np.random.random([6400, 100, 64, 1])
    y = np.random.randint(0, 100, [6400, 1])
    train = DataManage(x, y, con)

    x = np.random.random([640, 100, 64, 1])
    y = np.random.randint(0, 100, [640, 1])
    validation = DataManage(x, y, con)

    run(con, train, validation)
import pyasv.speech_processing
from pyasv.model import CTDnn
from pyasv import Config

root = "/opt/user1/fhq/asr/data-url/c863/"

config = Config(config_path="./test.json")

train_frames, train_labels = pyasv.speech_processing.ext_fbank_feature(root +
                                                                       'train')
enroll_frames, enroll_labels = pyasv.speech_processing.ext_fbank_feature(
    root + 'enroll')
test_frames, test_labels = pyasv.speech_processing.ext_fbank_feature(root +
                                                                     'test')

m = CTDnn(config)
m.run(train_frames, train_labels, enroll_frames, enroll_labels, test_frames,
      test_labels)
                    if i == j else tf.reduce_sum(mean_per_spkr[i, :] *
                                                 embeddings[j, :, :],
                                                 axis=1,
                                                 keep_dims=True)
                    for i in range(X)
                ],
                          axis=1) for j in range(X)
            ],
                          axis=0)
            # data shape is [spkr_num, utt_per_spkr, embedding_dim]
            # The shape of S is [spkr_num, utt_per_spkr, spkr_num]
            #S = ops.cosine(embeddings, mean_per_spkr, w=w, b=b)

            self.logger.debug(S.get_shape().as_list())

            S_per_spkr = tf.reduce_sum(S, axis=-1)

            self.logger.debug(S_per_spkr.get_shape().as_list())

            L = 2 * S - S_per_spkr

            self.logger.debug(L.get_shape().as_list())
        return tf.reduce_sum(L)


if __name__ == '__main__':
    x = tf.placeholder(dtpye=tf.float32, shape=[32, 150, 64])
    config = Config('lstmp.yaml')
    model = LSTMP(config, 400, 3)
    out = model.inference(x)
    model.loss(out)