Пример #1
0
int PoolingConn::constructWeights() {
    int sx = nfp;
    int sy = sx * nxp;
    int sp = sy * nyp;
    int nPatches = getNumDataPatches();
    int status = PV_SUCCESS;

    assert(!parent->parameters()->presentAndNotBeenRead(name, "shrinkPatches"));
    // createArbors() uses the value of shrinkPatches.  It should have already been read in ioParamsFillGroup.
    //allocate the arbor arrays:
    createArbors();

    setPatchStrides();

    for (int arborId=0; arborId<numAxonalArborLists; arborId++) {
        PVPatch *** wPatches = get_wPatches();
        status = createWeights(wPatches, arborId);
        assert(wPatches[arborId] != NULL);
        if (shrinkPatches_flag || arborId == 0) {
            status |= adjustAxonalArbors(arborId);
        }
    }  // arborId

    //call to initializeWeights moved to BaseConnection::initializeState()
    status |= initPlasticityPatches();
    assert(status == 0);
    if (shrinkPatches_flag) {
        for (int arborId=0; arborId<numAxonalArborLists; arborId++) {
            shrinkPatches(arborId);
        }
    }

    return status;

}
Пример #2
0
int MomentumConn::checkpointRead(const char * cpDir, double * timeptr) {
   HyPerConn::checkpointRead(cpDir, timeptr);
   if (!plasticityFlag) return PV_SUCCESS;
   clearWeights(prev_dwDataStart, getNumDataPatches(), nxp, nyp, nfp);
   char * path = parent->pathInCheckpoint(cpDir, getName(), "_prev_dW.pvp");
   PVPatch *** patches_arg = sharedWeights ? NULL : get_wPatches();
   double filetime=0.0;
   int status = PV::readWeights(patches_arg, prev_dwDataStart, numberOfAxonalArborLists(), getNumDataPatches(), nxp, nyp, nfp, path, parent->icCommunicator(), &filetime, pre->getLayerLoc());
   if (parent->columnId()==0 && timeptr && *timeptr != filetime) {
      fprintf(stderr, "Warning: \"%s\" checkpoint has timestamp %g instead of the expected value %g.\n", path, filetime, *timeptr);
   }
   free(path);
   return status;
}
Пример #3
0
//TODO checkpointing not working with batching, must write checkpoint exactly at period
int MomentumConn::checkpointWrite(const char * cpDir) {
   HyPerConn::checkpointWrite(cpDir);
   if (!plasticityFlag) return PV_SUCCESS;
   char filename[PV_PATH_MAX];
   int chars_needed = snprintf(filename, PV_PATH_MAX, "%s/%s_prev_dW.pvp", cpDir, name);
   if(chars_needed >= PV_PATH_MAX) {
      if ( parent->icCommunicator()->commRank()==0 ) {
         fprintf(stderr, "HyPerConn::checkpointFilename error: path \"%s/%s_W.pvp\" is too long.\n", cpDir, name);
      }
      abort();
   }
   PVPatch *** patches_arg = sharedWeights ? NULL : get_wPatches();
   int status = writeWeights(patches_arg, prev_dwDataStart, getNumDataPatches(), filename, parent->simulationTime(), writeCompressedCheckpoints, /*last*/true);
   assert(status==PV_SUCCESS);
   return PV_SUCCESS;
}