コード例 #1
0
 def test_get_output_for_cropped(self, crop_layer):
     from numpy.testing import assert_array_almost_equal as aeq
     x0 = numpy.random.random((5, 3))
     x1 = numpy.random.random((4, 2))
     inputs = [theano.shared(x0), theano.shared(x1)]
     result = crop_layer.get_output_for(inputs).eval()
     desired_result = 2 * x0[:4, :2] - x1[:4, :2]
     aeq(result, desired_result)
コード例 #2
0
ファイル: test_merge.py プロジェクト: AlTheEngineer/Lasagne
 def test_get_output_for_cropped(self, crop_layer):
     from numpy.testing import assert_array_almost_equal as aeq
     x0 = numpy.random.random((5, 3))
     x1 = numpy.random.random((4, 2))
     inputs = [theano.shared(x0),
               theano.shared(x1)]
     result = crop_layer.get_output_for(inputs).eval()
     desired_result = 2*x0[:4, :2] - x1[:4, :2]
     aeq(result, desired_result)
コード例 #3
0
ファイル: test_shape.py プロジェクト: Abushalaa/Lasagne
def test_slice_layer():
    from lasagne.layers import SliceLayer, InputLayer, get_output_shape,\
        get_output
    from numpy.testing import assert_array_almost_equal as aeq
    in_shp = (3, 5, 2)
    l_inp = InputLayer(in_shp)
    l_slice_ax0 = SliceLayer(l_inp, axis=0, indices=0)
    l_slice_ax1 = SliceLayer(l_inp, axis=1, indices=slice(3, 5))
    l_slice_ax2 = SliceLayer(l_inp, axis=-1, indices=-1)

    x = np.arange(np.prod(in_shp)).reshape(in_shp).astype('float32')
    x1 = x[0]
    x2 = x[:, 3:5]
    x3 = x[:, :, -1]

    assert get_output_shape(l_slice_ax0) == x1.shape
    assert get_output_shape(l_slice_ax1) == x2.shape
    assert get_output_shape(l_slice_ax2) == x3.shape

    aeq(get_output(l_slice_ax0, x).eval(), x1)
    aeq(get_output(l_slice_ax1, x).eval(), x2)
    aeq(get_output(l_slice_ax2, x).eval(), x3)

    # test slicing None dimension
    in_shp = (2, None, 2)
    l_inp = InputLayer(in_shp)
    l_slice_ax1 = SliceLayer(l_inp, axis=1, indices=slice(3, 5))
    assert get_output_shape(l_slice_ax1) == (2, None, 2)
    aeq(get_output(l_slice_ax1, x).eval(), x2)
コード例 #4
0
ファイル: test_shape.py プロジェクト: KeeganRen/Lasagne
def test_slice_layer():
    from lasagne.layers import SliceLayer, InputLayer, get_output_shape,\
        get_output
    from numpy.testing import assert_array_almost_equal as aeq
    in_shp = (3, 5, 2)
    l_inp = InputLayer(in_shp)
    l_slice_ax0 = SliceLayer(l_inp, axis=0, indices=0)
    l_slice_ax1 = SliceLayer(l_inp, axis=1, indices=slice(3, 5))
    l_slice_ax2 = SliceLayer(l_inp, axis=-1, indices=-1)

    x = np.arange(np.prod(in_shp)).reshape(in_shp).astype('float32')
    x1 = x[0]
    x2 = x[:, 3:5]
    x3 = x[:, :, -1]

    assert get_output_shape(l_slice_ax0) == x1.shape
    assert get_output_shape(l_slice_ax1) == x2.shape
    assert get_output_shape(l_slice_ax2) == x3.shape

    aeq(get_output(l_slice_ax0, x).eval(), x1)
    aeq(get_output(l_slice_ax1, x).eval(), x2)
    aeq(get_output(l_slice_ax2, x).eval(), x3)

    # test slicing None dimension
    in_shp = (2, None, 2)
    l_inp = InputLayer(in_shp)
    l_slice_ax1 = SliceLayer(l_inp, axis=1, indices=slice(3, 5))
    assert get_output_shape(l_slice_ax1) == (2, None, 2)
    aeq(get_output(l_slice_ax1, x).eval(), x2)
コード例 #5
0
 def test_mapping_to_physical(self):
     "Test mapping to the physical parameterization."
     map = generate_mapping('kipping', 'physical')
     aeq(map(self.p_k).pv, self.p_p.pv)
コード例 #6
0
 def test_mapping_to_orbit(self):
     "Test mapping to the orbit parameterization."
     aeq(self.p_k.map_to_orbit().pv, self.p_o.pv)
コード例 #7
0
 def test_mapping_to_kipping(self):
     "Test mapping the physical parameterization to the Kipping parameterization."
     map = generate_mapping('physical', 'kipping')
     aeq(map(self.p_p).pv, self.p_k.pv)
コード例 #8
0
 def test_mapping_to_orbit(self):
     "Map the orbit parameterization to itself"
     p_o = TransitParameterization('orbit', p_orbit)
     aeq(p_o.map_to_orbit().pv, p_o.pv)
コード例 #9
0
 def test_minimization(self):
     de = DiffEvol(lambda P:np.sum((P-1)**2), [[-2, 2], [-2, 2], [-2, 2]], 40, 100)
     aeq(de()[1], np.ones(3), 7, 'DiffEvol fitter fails to find the minimum.')
コード例 #10
0
 def test_mapping_to_physical(self):
     "Test mapping to the physical parameterization."
     map = generate_mapping('kipping', 'physical')
     aeq(map(self.p_k).pv, self.p_p.pv)
コード例 #11
0
 def test_mapping_to_orbit(self):
     "Test mapping to the orbit parameterization."
     aeq(self.p_k.map_to_orbit().pv, self.p_o.pv)
コード例 #12
0
 def test_mapping_to_kipping(self):
     "Test mapping the physical parameterization to the Kipping parameterization."
     map = generate_mapping('physical', 'kipping')
     aeq(map(self.p_p).pv, self.p_k.pv)
コード例 #13
0
 def test_mapping_to_orbit(self):
     "Map the orbit parameterization to itself"
     p_o = TransitParameterization('orbit', p_orbit)
     aeq(p_o.map_to_orbit().pv, p_o.pv)