Esempio n. 1
0
def structure_weights(dataset, w):
    *_, single, pair = dataset
    num_single = [factor.num_weights(f) for f in single]
    num_pair = [factor.num_weights(f) for f in pair]

    start = 0
    single_weights = []
    for n in num_single:
        end = start + n
        w_new = w[start:end]
        single_weights.append(w_new)
        start += n

    pair_weights = []
    for n in num_pair:
        end = start + n
        w_new = w[start:end]
        pair_weights.append(w_new)
        start += n

    return single_weights, pair_weights
Esempio n. 2
0
def total_weights(dataset):
    *_, single, pair = dataset
    n = 0
    n += sum(factor.num_weights(f) for f in single)
    n += sum(factor.num_weights(f) for f in pair)
    return n