コード例 #1
0
ファイル: saccade.py プロジェクト: wiktor-b/topographica
def activity_sample(sheet,activity=None):
    """
    Sample from the sheet activity as if it were a probability distribution.

    Returns the sheet coordinates of the sampled unit.  If
    activity is not None, it is used instead of sheet.activity.
    """

    if activity is None:
        activity = sheet.activity
    idx = util.weighted_sample_idx(activity.ravel())
    r,c = util.idx2rowcol(idx,activity.shape)

    return sheet.matrix2sheet(r,c)
コード例 #2
0
def activity_sample(sheet, activity=None):
    """
    Sample from the sheet activity as if it were a probability distribution.

    Returns the sheet coordinates of the sampled unit.  If
    activity is not None, it is used instead of sheet.activity.
    """

    if activity is None:
        activity = sheet.activity
    idx = util.weighted_sample_idx(activity.ravel())
    r, c = util.idx2rowcol(idx, activity.shape)

    return sheet.matrix2sheet(r, c)
コード例 #3
0
ファイル: saccade.py プロジェクト: wiktor-b/topographica
def activity_mode(sheet,activity=None):
    """
    Returns the sheet coordinates of the mode (highest value) of
    the sheet activity.   
    """

    # JPHACKALERT:  The mode is computed using numpy.argmax, and
    # thus for distributions with multiple equal-valued modes, the
    # result will have a systematic bias toward higher x and lower
    # y values. (in that order).  Function may still be useful for
    # unimodal activity distributions, or sheets without limiting/squashing
    # output functions.
    if activity is None:
        activity = sheet.activity
    idx = argmax(activity.flat)
    r,c = util.idx2rowcol(idx,activity.shape)
    return sheet.matrix2sheet(r,c)
コード例 #4
0
def activity_mode(sheet, activity=None):
    """
    Returns the sheet coordinates of the mode (highest value) of
    the sheet activity.
    """

    # JPHACKALERT:  The mode is computed using numpy.argmax, and
    # thus for distributions with multiple equal-valued modes, the
    # result will have a systematic bias toward higher x and lower
    # y values. (in that order).  Function may still be useful for
    # unimodal activity distributions, or sheets without limiting/squashing
    # output functions.
    if activity is None:
        activity = sheet.activity
    idx = argmax(activity.flat)
    r, c = util.idx2rowcol(idx, activity.shape)
    return sheet.matrix2sheet(r, c)