fix comments in cr;add inferred dimension test

This commit is contained in:
Cheng Tang 2017-07-22 20:29:49 -07:00
Родитель f4e9df1242
Коммит d86f020081
3 изменённых файлов: 14 добавлений и 5 удалений

Просмотреть файл

@ -1287,7 +1287,7 @@ namespace CNTK
FunctionPtr UnpackBatch(const Variable& operand, const std::wstring& name)
{
if (operand.DynamicAxes().size() > 1)
LogicError("UnpackBatch: only support input with batch axis itself.");
LogicError("UnpackBatch: only support input with batch axis and n sequence axis.");
return UnaryOp(PrimitiveOpType::UnpackBatch, operand, Dictionary(), name);
}

Просмотреть файл

@ -434,10 +434,8 @@ namespace CNTK
InvalidArgument("AssignNode: Ref operand must be constant or parameter only.");
//delay the check for free dimension
if (m_inputs[0].Shape() != m_inputs[1].Shape() &&
!m_inputs[0].Shape().HasFreeDimension() &&
!m_inputs[1].Shape().HasFreeDimension() &&
!m_inputs[0].Shape().HasInferredDimension() &&
!m_inputs[1].Shape().HasInferredDimension())
!m_inputs[0].Shape().HasUnboundDimension() &&
!m_inputs[1].Shape().HasUnboundDimension())
{
InvalidArgument("AssignNode: All inputs should have same sample layout.");
}

Просмотреть файл

@ -516,3 +516,14 @@ def test_convert_dynamic_axis():
z = y * 2
expected = data.reshape((8, 3)) * 2
assert np.array_equal(z.eval({x:data}), expected)
#test inferred dimension
x = C.input_variable((C.InferredDimension, 3))
const_x = C.unpack_batch(x)
assert len(const_x.dynamic_axes) == 0
assert const_x.shape == (C.FreeDimension, C.InferredDimension, 3)
const_y = const_x * 2
y = C.to_batch(const_y)
assert len(y.dynamic_axes) == 1
assert y.shape == (C.InferredDimension, 3)