Пример #1
0
def test_InceptionV1Structure():
    n_classes = 10
    # model_types = [1, 2, 3, 4]
    model_types = [1]
    for model_type in model_types:
        print(f'test_model_type= {model_type}')
        x = tf.placeholder(tf.float32, [None, 128, 128, 3])
        net = InceptionV1NetModule(x, n_classes, model_type=model_type)
        with elapse_time('build'):
            net.build()

        x_np = np.random.normal(0, 1, [10, 128, 128, 3])
        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())

            with elapse_time('net proba forward time'):
                forward = sess.run(net.proba, feed_dict={x: x_np})
            print(forward.shape)
            with elapse_time('aux0 proba forward time'):
                forward = sess.run(net.aux0_proba, feed_dict={x: x_np})
            print(forward.shape)
            with elapse_time('aux1 proba forward time'):
                forward = sess.run(net.aux1_proba, feed_dict={x: x_np})

            print(forward.shape)
Пример #2
0
def test_ResNet101Structure():
    x = tf.placeholder(tf.float32, [None, 128, 128, 3])
    n_classes = 10

    net = ResNet101Structure(x, n_classes)
    with elapse_time('build'):
        net.build()

    h = net.proba
    x_np = np.random.normal(0, 1, [10, 128, 128, 3])
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())

        with elapse_time('forward time'):
            forward = sess.run(h, feed_dict={x: x_np})

        print(forward.shape)
Пример #3
0
def test_NpSharedObj():
    shape = [3, 3]
    mat = np.ones(shape)
    shared_obj = NpSharedObj.from_np(mat)
    print(shared_obj.np)

    print(f'share memory')
    with Pool(processes=1, initializer=init_shared, initargs=(shared_obj.loc, shape,)) as pool:
        with elapse_time():
            childs = [pool.apply_async(func2, args=(args,)) for args in range(16)]

            for child in childs:
                a = child.get()
                print(a)

    print(f'exit')
    print(shared_obj.np)