コード例 #1
0
def test_base_model_inheritance_ver1(clean_config):
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    m1 = Conv2D('conv', 32, 3)
    m2 = Dense('dense', 160)
    m3 = Stack([m1, m2])
    res1 = m3(x)
    assert shape(res1) == [32, 64, 64, 160]
コード例 #2
0
def test_base_model_inheritance_ver2(clean_config):
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    m4 = Conv2D('conv', 160, 3)
    m9 = Dense('dense', 160)
    x = m9(x)
    m5 = Residual('res', m4)
    res2 = m5(x)
    assert shape(res2) == [32, 64, 64, 160]
コード例 #3
0
def test_base_model_inheritance_ver3(clean_config):
    x = tf.ones([32, 64, 64, 160], dtype=tf.float32)
    m1 = Conv2D('conv1', 32, 3)
    m7 = Conv2D('conv2', 3, 3)
    m8 = Dense('dense', 128)
    m6 = Inception('inception', m7, m7, [m1, m8])
    res3 = m6(x)
    assert shape(res3) == [32, 64, 64, 3]
コード例 #4
0
def test_Inception_basic(clean_config):
    x = tf.constant(np.ones([32, 64, 64, 3], np.float32))
    m1 = Conv2D('conv3', 64, 3)
    m2 = Dense('dense1', 128)
    paths = [Conv2D('conv_{}'.format(i), 32 + 32 * i, 3) for i in range(3)]
    m = Inception('inception1', m1, m2, paths)
    y = m(x)
    assert shape(y) == [32, 64, 64, 128]
コード例 #5
0
ファイル: test_stack.py プロジェクト: tech-pi/dxlearn
def test_stack_basic(clean_config):
    models = [
        Conv2D('conv1', 64, 3),
        Conv2D('conv2', 128, 3),
        Conv2D('conv3', 256, 3)
    ]
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    st = Stack(models)
    res = st(x)
    assert shape(res) == [32, 64, 64, 256]
コード例 #6
0
def test_merge_basic(clean_config):
    m1 = Dense('d1', 256)
    m2 = Conv2D('conv1', 64, 3)
    m3 = Conv2D('conv2', 128, 3)
    concate = partial(concat, axis=3)
    m = Merge(merger=concate, models=[m2, m3])
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    res = m(x)
    res = m1(res)
    assert shape(res) == [32, 64, 64, 256]
コード例 #7
0
ファイル: test_residual.py プロジェクト: tech-pi/dxlearn
def test_residual_basic(clean_config):
    m1 = Conv2D('conv1', 3, 3)
    r = Residual('res1', m1)
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    res1 = r(x)
    res2 = m1(x)
    assert shape(res1) == [32, 64, 64, 3]
    with tf.Session() as sess:
        sess.run(tf.global_variables_initializer())
        a, b = sess.run([res1, res2])
        assert all_close(a, b) is False
コード例 #8
0
 def shape(self):
     return shape(self.data)
コード例 #9
0
def _(t):
    return shape(t.unbox())
コード例 #10
0
def _(t, nb_partition, id_partition, axis=0):
    with tf.variable_scope('split_with_index'):
        return tf.slice(
            t, split_start(shape(t), nb_partition, id_partition, axis),
            split_shape(shape(t), nb_partition, id_partition, axis))
コード例 #11
0
ファイル: listmode.py プロジェクト: tech-pi/SRF
def _(raw_data):
    return ListModeDataWithoutTOF(const[backends.TensorFlowBackend](raw_data.astype(np.float32), name='lors'),
                                  const[backends.TensorFlowBackend](np.ones([shape(raw_data)[0], 1], dtype=np.float32),
                                                                    name='values'))
コード例 #12
0
def test_conv2d_basic(tensorflow_test):
    m = Conv2D('conv1', 64, 3)
    x = tf.constant(np.ones([32, 64, 64, 3], np.float32))
    y = m(x)
    assert shape(y) == [32, 64, 64, 64]
コード例 #13
0
def test_upsampling_basic(clean_config):
    m1 = UpSampling2D('ups1', (2, 2), method=2)
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    res = m1(x)
    assert shape(res) == [32, 128, 128, 3]
コード例 #14
0
def test_downsampling_basic(clean_config):
    m1 = DownSampling2D('dsp1', (3, 3), (1, 1), 'valid')
    x = tf.ones([32, 64, 64, 3], dtype=tf.float32)
    res = m1(x)
    assert shape(res) == [32, 62, 62, 3]