def __init__(self): grid_size = 16 # HEURISTICS: radius = (1/3)*2^(ENCODING_SIZE) # where ENCODING_SIZE is bit size of every pattern element (8 bits for us) radius = 24 # Calculate pattern size based on grid_size and size of a Nibble (4) pattern_size = pow(grid_size, 2) / 4 # Set neural network data size RbfNetwork.PATTERN_SIZE = pattern_size # Set neural network default radius RbfNetwork.DEFAULT_RADIUS = radius # Set pattern size in RBF knowledge RbfKnowledge.PATTERN_SIZE = pattern_size # If there are no persisten memory related files, create them if not os.path.isfile("persistent_memory/sight_snb.p"): self.erase_all_knowledge() # SNB self.snb = SensoryNeuralBlock("persistent_memory/sight_snb.p", "persistent_memory/hearing_snb.p") # Relational Neural Block self.rnb = RelNetwork.deserialize("persistent_memory/rnb.p") # Analytical neuron self.analytical_n = AnalyticalNeuron() # Addition by memory network self.am_net = CulturalNetwork.deserialize("persistent_memory/am_net.p") # Geometric Neural Block self.gnb = GeometricNeuralBlock.deserialize("persistent_memory/gnb.p") # Syllables net self.syllables_net = CulturalNetwork.deserialize( "persistent_memory/syllables_net.p") # Words net self.words_net = CulturalNetwork.deserialize( "persistent_memory/words_net.p") # Sight-Syllables rel network self.ss_rnb = RelNetwork.deserialize("persistent_memory/ss_rnb.p") # ################### INTENTIONS MODULES ######################################################################## self.episodic_memory = EpisodicMemoriesBlock.deserialize( "persistent_memory/episodic_memory.p") self.decisions_block = DecisionsBlock.deserialize( "persistent_memory/decisions_block.p") self.internal_state = InternalState.deserialize( "persistent_memory/internal_state.p") self.desired_state = InternalState.deserialize( "persistent_memory/desired_state.p") # Internal state "Ports" (Three components real valued vector) self._internal_state_in = None # Memory that stores short term bip inputs for making a decision self._intentions_short_term_memory = [] self._output_memory = None # ############################################################################################################### # _bbcc_words self._learning_words = False self._learning_syllables = False self._enable_bbcc = False # Output "ports" (related to senses) self.s_knowledge_out = None self.h_knowledge_out = None # Input "ports" (senses) self.s_knowledge_in = None self.h_knowledge_in = None self._working_domain = "ADDITION" self.state = "MISS"
def __init__(self, user, project, frontend_request): grid_size = 16 # HEURISTICS: radius = (1/3)*2^(ENCODING_SIZE) # where ENCODING_SIZE is bit size of every pattern element (8 bits for us) radius = 24 # Calculate pattern size based on grid_size and size of a Nibble (4) pattern_size = pow(grid_size, 2) / 4 # Set neural network data size RbfNetwork.PATTERN_SIZE = pattern_size # Set neural network default radius RbfNetwork.DEFAULT_RADIUS = radius # Set pattern size in RBF knowledge RbfKnowledge.PATTERN_SIZE = pattern_size # If there are no persisten memory related files, create them self.user = user self.hearing_id = -1 if frontend_request == "CREATE": self.brain = brain(user=self.user, name=project) self.brain.save() self.project_id = self.brain.id self.project_name = project self.create_kernel() self.message = 'the brain has been created successfully, the id is ' + str( self.project_id) if frontend_request == "LOAD": self.project_id = project # SNB self.snb = SensoryNeuralBlock("snb_s", "snb_h", self.project_id) #print(self.snb.snb_h.__dict__) #for i in self.snb.snb_h.neuron_list: #if i._knowledge!= None: #print(i._knowledge) # Relational Neural Block self.rnb = RelNetwork.deserialize("rnb", self.project_id) #print(self.rnb.__dict__) #for i in self.rnb.neuron_list: #if i._knowledge!= None: #print(i.__dict__) #print(i._knowledge.__dict__) # Addition by memory network self.am_net = CulturalNetwork.deserialize("am_net", self.project_id) #print(self.am_net.__dict__) #for i in self.am_net.group_list: #if i._knowledge!= None: #print(i.__dict__) # Geometric Neural Block self.gnb = GeometricNeuralBlock.deserialize("gnb", self.project_id) #print(self.gnb.__dict__) #for i in self.gnb._addition_structure.neurons: #if i._knowledge!= None: #print(i.__dict__) # Syllables net self.syllables_net = CulturalNetwork.deserialize( "syllables_net", self.project_id) #print(self.syllables_net.__dict__) #for i in self.syllables_net.group_list: #if i._knowledge!= None: #print(i.__dict__) # Words net self.words_net = CulturalNetwork.deserialize( "words_net", self.project_id) #print(self.words_net.__dict__) #for i in self.words_net.group_list: #if i._knowledge!= None: #print(i.__dict__) # Sight-Syllables rel network self.ss_rnb = RelNetwork.deserialize("ss_rnb", self.project_id) #print(self.ss_rnb.__dict__) # for i in self.ss_rnb.neuron_list: # if i._knowledge!= None: # print(i._knowledge.__dict__) #################### INTENTIONS MODULES ######################################################################## self.episodic_memory = EpisodicMemoriesBlock.deserialize( "episodic_memory", self.project_id) #print(self.episodic_memory.__dict__) #for i in self.episodic_memory.group_list: #print(i.__dict__) #for k in i.group: #print(k.__dict__) # if isinstance(k._knowledge, int): # asd=int(k._knowledge) # print(asd) # else: # print(k._knowledge.__dict__) self.decisions_block = DecisionsBlock.deserialize( "decisions_block", self.project_id) #print(self.decisions_block.__dict__) #print(self.decisions_block.conscious_block.decision_prediction_block.predictive_net.__dict__) self.internal_state = InternalState.deserialize( "internal_state", self.project_id) #print('internal',self.internal_state.__dict__) self.desired_state = InternalState.deserialize( "desired_state", self.project_id) #print('desired',self.desired_state.__dict__) self.message = "BRAIN SUCCESFULLY LOADED" ################################################# NON-deserialize data################ # Analytical neuron self.analytical_n = AnalyticalNeuron() #print(self.analytical_n.__dict__) # Internal state "Ports" (Three components real valued vector) self._internal_state_in = None # Memory that stores short term bip inputs for making a decision self._intentions_short_term_memory = [] self._output_memory = None # ############################################################################################################### # _bbcc_words self._learning_words = False self._learning_syllables = False self._enable_bbcc = False # Output "ports" (related to senses) self.s_knowledge_out = None self.h_knowledge_out = None # Input "ports" (senses) self.s_knowledge_in = None self.h_knowledge_in = None self._working_domain = "ADDITION" self.state = "MISS"