Sergey
July 28, 2017, 9:08pm
1
Hello
Do you have some information about the fourth parameters linkParams in function links. network.link(‘Region from’, ‘Region to’, ‘UniformLink’, ‘What is sent by these parameters’) Where can I find docs or examples about linkParams ?
Thanx a lot !
You are right @Sergey , there’s not much info on Network.link
in the API docs. @scott Do you know anywhere in our code where this is explained?
scott
July 31, 2017, 6:22pm
3
The last argument contains yaml-serialized parameters that are specific to the link policy. This gets passed to links as “linkParams” in the C++ engine code:
*
* @todo It seems this constructor should be deprecated in favor of the other,
* which is less redundant. This constructor is being used for unit testing
* and unit testing links and for deserializing networks.
*
* See comments below commonConstructorInit_()
*
* @endinternal
*
*/
Link(const std::string& linkType, const std::string& linkParams,
const std::string& srcRegionName, const std::string& destRegionName,
const std::string& srcOutputName="",
const std::string& destInputName="",
const size_t propagationDelay=0);
/**
* De-serialization use case. Creates a "blank" link. The caller must follow
* up with Link::read and Link::connectToNetwork
*
* @param proto
which passes it to “createLinkPolicy”:
destInputName_ = destInputName;
propagationDelay_ = propagationDelay;
destOffset_ = 0;
srcOffset_ = 0;
srcSize_ = 0;
src_ = nullptr;
dest_ = nullptr;
initialized_ = false;
impl_ = LinkPolicyFactory().createLinkPolicy(linkType, linkParams, this);
}
Link::~Link()
{
delete impl_;
}
void Link::initPropagationDelayBuffer_(size_t propagationDelay,
NTA_BasicType dataElementType,
which passes them into the link type construction, which is currently hard-coded here:
LinkPolicy *lp = nullptr;
if (policyType == "TestFanIn2")
{
lp = new TestFanIn2LinkPolicy(policyParams, link);
} else if (policyType == "UniformLink")
{
lp = new UniformLinkPolicy(policyParams, link);
} else if (policyType == "UnitTestLink")
{
// When unit testing a link policy, a valid Link* is required to be passed
// to the link policy's constructor. If you pass NULL, other portions of
// NuPIC may try to dereference it (e.g. operator<< from NTA_THROW). So we
// allow for a UnitTestLink link policy which doesn't actually provide
// anything. This way, you can create a dummy link like so:
//
// Link dummyLink("UnitTestLink", "", "", "");
//
// and pass this dummy link to the constructor of the real link policy
// you wish to unit test.
} else if (policyType == "TestSplit")
This file has been truncated. show original
1 Like
scott
July 31, 2017, 6:23pm
4
And FWIW, we usually just use UniformLink without any parameters but if you are curious you can look at the individual link policy classes to see what parameters they support. Here is UniformLink as an example:
readParameters(params);
validateParameterDimensionality();
populateWorkingParameters();
validateParameterConsistency();
}
UniformLinkPolicy::~UniformLinkPolicy()
{
}
void UniformLinkPolicy::readParameters(const std::string& params)
{
ValueMap paramMap = YAMLUtils::toValueMap(params.c_str(), parameters_);
boost::shared_ptr<std::string> mappingStr = paramMap.getString("mapping");
if(*mappingStr == "in")
{
mapping_ = inMapping;
}
else if(*mappingStr == "out")
1 Like