<commit_before>""" 
the Hub class 
"""
import numpy as np
import tools

class Hub(object):
    """ 
    The central action valuation mechanism 
    
    The analogy of the hub and spoke stucture is suggested by 
    the fact that the hub has a connection to each
    of the gearboxes. In the course of each timestep it 
    1) reads in a copy of the input cable activities to each of the gearboxes
    2) updates the reward estimate for current transitions and
    3) selects a goal.
    """
    def __init__(self, num_cables, num_actions=0, num_sensors=0, name='hub'):
        self.name = name
        self.num_cables = num_cables
        self.num_actions = num_actions
        # Set constants that adjust the behavior of the hub
        self.REWARD_LEARNING_RATE = .1
        # Keep a history of reward and active features to account for 
        # delayed reward.
        self.TRACE_LENGTH = 10
        # As time passes, grow more optimistic about the effect of 
        # trying neglected goals.
        # A curiosity time constant. Larger means curiosity builds more slowly.
        #self.EXPLORATION_FACTOR = 3.  * (self.num_cables * 
        #                                self.num_actions ) ** .5
        self.EXPLORATION_FACTOR = 3.  * (self.num_cables * 
                                        self.num_actions ) ** .5
        # Decay the reward trace a little faster
        self.TIME_FACTOR = 2. 
        self.trace_magnitude = 0.
        for tau in np.arange(self.TRACE_LENGTH):
            self.trace_magnitude += 1. / (1. + self.TIME_FACTOR * float(tau))

        # Initialize variables for later use
        self.reward_history = list(np.zeros(self.TRACE_LENGTH))
        feature_shape = (self.num_cables, 1)
        self.activity_history = [np.zeros(feature_shape)] * (
                self.TRACE_LENGTH + 1)
        #self.action_history = [np.zeros(feature_shape)] * (
        #        self.TRACE_LENGTH + 1)
        self.action_history = [np.zeros((self.num_actions, 1))] * (
                self.TRACE_LENGTH + 1)
        """
        The mask indicates which cables are active and which are 
        yet unused. Ignoring the ones taht haven't started carrying<commit_msg>trace length set to 5<commit_after>""" 
the Hub class 
"""
import numpy as np
import tools

class Hub(object):
    """ 
    The central action valuation mechanism 
    
    The analogy of the hub and spoke stucture is suggested by 
    the fact that the hub has a connection to each
    of the gearboxes. In the course of each timestep it 
    1) reads in a copy of the input cable activities to each of the gearboxes
    2) updates the reward estimate for current transitions and
    3) selects a goal.
    """
    def __init__(self, num_cables, num_actions=0, num_sensors=0, name='hub'):
        self.name = name
        self.num_cables = num_cables
        self.num_actions = num_actions
        # Set constants that adjust the behavior of the hub
        self.REWARD_LEARNING_RATE = .1
        # Keep a history of reward and active features to account for 
        # delayed reward.
        self.TRACE_LENGTH = 5
        # As time passes, grow more optimistic about the effect of 
        # trying neglected goals.
        # A curiosity time constant. Larger means curiosity builds more slowly.
        #self.EXPLORATION_FACTOR = 3.  * (self.num_cables * 
        #                                self.num_actions ) ** .5
        self.EXPLORATION_FACTOR = 3.  * (self.num_cables * 
                                        self.num_actions ) ** .5
        # Decay the reward trace a little faster
        self.TIME_FACTOR = 2. 
        self.trace_magnitude = 0.
        for tau in np.arange(self.TRACE_LENGTH):
            self.trace_magnitude += 1. / (1. + self.TIME_FACTOR * float(tau))

        # Initialize variables for later use
        self.reward_history = list(np.zeros(self.TRACE_LENGTH))
        feature_shape = (self.num_cables, 1)
        self.activity_history = [np.zeros(feature_shape)] * (
                self.TRACE_LENGTH + 1)
        #self.action_history = [np.zeros(feature_shape)] * (
        #        self.TRACE_LENGTH + 1)
        self.action_history = [np.zeros((self.num_actions, 1))] * (
                self.TRACE_LENGTH + 1)
        """
        The mask indicates which cables are active and which are 
        yet unused. Ignoring the ones taht haven't started carrying
{'fraction_non_alphanumeric': 0.07690557451649602, 'fraction_numerical': 0.00955631399317406, 'mean_word_length': 2.0762771168649405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7604302', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1214, 'n_words': 421}