示例#1
0
def segment_packed_corr(segments, width=None):
    # correlation over time within each segment
    if width is None:
        width = segments.tag.shape[2]
    try:
        n_segments = segments.tag.shape[0]
    except AttributeError:
        n_segments = segments.shape[0]
    packing_matrix = pack_symmatrix_spmat(width)
    corr = custom_corr(segments).reshape((n_segments, width ** 2))
    rval = theano.sparse.structured_dot(corr, packing_matrix)
    if corr.type.broadcastable[0]:
        # sparse matrices have no broadcastable property,
        # so the broadcastable[0] is always False, even when it shouldn't be
        rval = theano.tensor.Rebroadcast((0, True))(rval)
    return rval
示例#2
0
def segment_corr(segments):
    # correlation over time within each segment
    n_segments = segments.shape[0]
    width = segments.shape[2]
    return custom_corr(segments).reshape((n_segments, width ** 2))