Can't load RC1 models that perform reduction over all axes or all static axes
Problem:
I've trained some old models and I've used reduce_sum(x, axis=Axis.all_axes()) and reduce_sum(x, axis=Axis.all_static_axes()) to calculate some metrics over all elements of a mini-batch. I've recently updated to the release version of CNTK and I wasn't able to load the old models since. There seems to be a size mismatch of some nodes in the network.
Problem tracking:
I've retrained the models with the release version to check was has changed and found that the reduction operations now has the additional parameter AttributeNameReductionKeepDimensions, which is always set to true if not present in an old model. However, for the reduction over all axes or all static axes, this parameter defaults to false when I retrained the model.
Potential solution:
I've modifed CNTK to set the default value of the parameter AttributeNameReductionKeepDimensions to false, iff the reduction is performed either over all axes or all static axes, instead of always true, in order to match the new behaviour and this seems to fix the issue. Do you think this is a valid fix or will this cause trouble in other circumstances?
Code changes:
In CompositeFunction.cpp
case PrimitiveOpType::ReduceElements:
{
//bool keepDimensions = false;
auto reductionAxis = functionConfig[PrimitiveFunction::AttributeNameAxis].Value<Axis>();
bool keepDimensions = reductionAxis != Axis::AllStaticAxes() && reductionAxis != Axis::AllAxes(); // changed default to what the new default seems to be
if (functionConfig.Contains(PrimitiveFunction::AttributeNameReductionKeepDimensions))
keepDimensions = functionConfig[PrimitiveFunction::AttributeNameReductionKeepDimensions].Value<bool>();
//...
}
In PrimitiveFunction.cpp
case PrimitiveOpType::ReduceElements:
{
assert(m_inputs.size() == 1);
auto reductionAxis = NormalizeAxis(m_attributes[PrimitiveFunction::AttributeNameAxis].Value<Axis>(), m_inputs[0]);
bool keepDimensions = reductionAxis != Axis::AllStaticAxes() && reductionAxis != Axis::AllAxes(); // changed default to what the new default seems to be
if (m_attributes.Contains(PrimitiveFunction::AttributeNameReductionKeepDimensions))
keepDimensions = m_attributes[PrimitiveFunction::AttributeNameReductionKeepDimensions].Value<bool>();
// ...
}
I think you should submit a pull request and our tests can tell us if there are corner cases
@e-thereal , has this issue been resolved?
Unfortunately, I can't create a pull request, because we've already deviated too much from the master branch to create a simple diff, or I don't know git well enough to do it. The changes haven't resulted in any issues so far, so it is OK as far as I'm concerned. And since others don't seem to have this issue, you may close the issue. There used to be frequent releases during the beta testing and RC phase. Is there any new release planned yet that I could use to test if the issue still remains?
Yes, there is a planned release 7/30. Our iteration plans are now public: https://github.com/Microsoft/CNTK/wiki/Iteration-Plans
I'm closing this issue now. If the new release still has this issue, please reopen.