Esempio n. 1
0
def make_action(locations, effects, keys, location_indices, effect_indices):
    location_sum = np.sum(locations.vectors[:, location_indices], axis=1)
    effect_sum = np.sum(effects.vectors[:, effect_indices], axis=1)
    vector = hrr.bind(keys.get('LOCATION'), location_sum,
                      do_normalize=False) + hrr.bind(
                          keys.get('EFFECT'), effect_sum, do_normalize=False)
    return vector
Esempio n. 2
0
def make_thing(locations, goals, keys, location_indices, goal_indices):
    # make an object HRR vector with these associated locations and goals
    location_sum = np.sum(locations.vectors[:, location_indices], axis=1)
    goal_sum = np.sum(goals.vectors[:, goal_indices], axis=1)
    vector = hrr.bind(keys.get('LOCATION'), location_sum,
                      do_normalize=False) + hrr.bind(
                          keys.get('GOAL'), goal_sum, do_normalize=False)
    return vector
Esempio n. 3
0
def make_affordance(things, effects, keys, thing_index, effect_indices):
    #normalize each thing vector for use as affordance component
    v = things.vectors[:,thing_index].copy()
    for i in range(v.shape[1]):
        v[:,i] = hrr.normalize(v[:,i])

    # thing_sum = np.sum(things.vectors[:,thing_index], axis=1)
    thing_sum = np.sum(v, axis=1)
    effect_sum = np.sum(effects.vectors[:,effect_indices], axis=1)
    vector = hrr.bind(keys.get('THING'), thing_sum, do_normalize=False) + hrr.bind(keys.get('EFFECT'), effect_sum, do_normalize=False)
    return vector
Esempio n. 4
0
def make_affordance(things, effects, keys, thing_index, effect_indices):
    #normalize each thing vector for use as affordance component
    v = things.vectors[:, thing_index].copy()
    for i in range(v.shape[1]):
        v[:, i] = hrr.normalize(v[:, i])

    # thing_sum = np.sum(things.vectors[:,thing_index], axis=1)
    thing_sum = np.sum(v, axis=1)
    effect_sum = np.sum(effects.vectors[:, effect_indices], axis=1)
    vector = hrr.bind(keys.get('THING'), thing_sum,
                      do_normalize=False) + hrr.bind(
                          keys.get('EFFECT'), effect_sum, do_normalize=False)
    return vector
Esempio n. 5
0
def make_random_cleanup(n, prefix, keys, labels, cleanups, counts, D):
    """
    n - number of concepts in cleanup
    prefix - prefix for concept names (to be appended with a number)
    keys - cleanup of data types (LOCATION, GOAL, etc.)
    cleanups - tuple of cleanup memories from which parts of the created concepts will be drawn
    labels - tuple of labels (e.g. 'LOCATION') of parts
    counts - tuple of counts (each length n) of summed components from each cleanup
    """
    assert len(labels) == len(cleanups)
    assert len(labels) == len(counts)

    cleanup = hrr.CleanupMemory([prefix + str(l) for l in range(n)], D)
    indices = []
    for i in range(n):
        indices_i = []
        vector = np.zeros(D)
        for j in range(len(labels)):
            indices_ij = np.random.randint(0,
                                           len(cleanups[j].concepts),
                                           size=counts[j][i])
            s = np.sum(cleanups[j].vectors[:, indices_ij], axis=1)
            vector = vector + hrr.bind(
                keys.get(labels[j]), s, do_normalize=False)
            indices_i.append(indices_ij)
        cleanup.replace(cleanup.concepts[i], vector)
        indices.append(indices_i)
    cleanup.indices = indices
    return cleanup
Esempio n. 6
0
def make_random_cleanup(n, prefix, keys, labels, cleanups, counts, D):
    """
    n - number of concepts in cleanup
    prefix - prefix for concept names (to be appended with a number)
    keys - cleanup of data types (LOCATION, GOAL, etc.)
    cleanups - tuple of cleanup memories from which parts of the created concepts will be drawn
    labels - tuple of labels (e.g. 'LOCATION') of parts
    counts - tuple of counts (each length n) of summed components from each cleanup
    """
    assert len(labels) == len(cleanups)
    assert len(labels) == len(counts)

    cleanup = hrr.CleanupMemory([prefix + str(l) for l in range(n)], D)
    indices = []
    for i in range(n):
        indices_i = []
        vector = np.zeros(D)
        for j in range(len(labels)):
            indices_ij = np.random.randint(0, len(cleanups[j].concepts), size=counts[j][i])
            s = np.sum(cleanups[j].vectors[:,indices_ij], axis=1)
            vector = vector + hrr.bind(keys.get(labels[j]), s, do_normalize=False)
            indices_i.append(indices_ij)
        cleanup.replace(cleanup.concepts[i], vector)
        indices.append(indices_i)
    cleanup.indices = indices
    return cleanup
Esempio n. 7
0
def make_action(locations, effects, keys, location_indices, effect_indices):
    location_sum = np.sum(locations.vectors[:,location_indices], axis=1)
    effect_sum = np.sum(effects.vectors[:,effect_indices], axis=1)
    vector = hrr.bind(keys.get('LOCATION'), location_sum, do_normalize=False) + hrr.bind(keys.get('EFFECT'), effect_sum, do_normalize=False)
    return vector
Esempio n. 8
0
def make_thing(locations, goals, keys, location_indices, goal_indices):
    # make an object HRR vector with these associated locations and goals
    location_sum = np.sum(locations.vectors[:,location_indices], axis=1)
    goal_sum = np.sum(goals.vectors[:,goal_indices], axis=1)
    vector = hrr.bind(keys.get('LOCATION'), location_sum, do_normalize=False) + hrr.bind(keys.get('GOAL'), goal_sum, do_normalize=False)
    return vector