コード例 #1
0
 def __init__(self,memory_size=1000,memory_word_size=32):
     self.Gmemory = nx.DiGraph()
     self.StateAttributesDict={}
     self.memory_size = memory_size
     self.memory_word_size = memory_word_size
     self.gamma = 0.9
     self.lr = 0.01   
          
     self._write_content_similarity = utils.CosineSimilarity(1,self.memory_word_size,name="write_content_similarity")
     self._TH = 0.99
コード例 #2
0
 def __init__(self,
              num_actions=4,
              num_node=10,
              memory_size=100,
              memory_word_size=100,
              name='ControllerCore'):
     #self.AbstractG = self._build_graph()
     #由于目前还没有构造抽象图 20200430
     #所以用原图代替
     self.memory_size = memory_size
     self.AbstractG = Memory.ExternalMemory(memory_size=self.memory_size)
     self._read_content_similarity = utils.CosineSimilarity(
         1, word_size=memory_word_size, name="read_content_similarity")
     self.epsilon = 0.9
     self.num_actions = num_actions
     self.aggregator_cls = MeanAggregator
     self.memory_word_size = memory_word_size
     self.aggregator = self.aggregator_cls(self.memory_word_size,
                                           self.memory_word_size,
                                           name="aggregator",
                                           concat=False)
コード例 #3
0
 def __init__(self,
              num_actions=4,
              num_node=10,
              memory_size=100,
              memory_word_size=32,
              name='ControllerCore'):
     # 外部存储的结构概览
     self.memory_size = memory_size
     self.memory_word_size = memory_word_size
     # 构造抽象图,从Memory中重新实例化一个子图,作为抽象图
     self.AbstractG = Memory.ExternalMemory(memory_size=self.memory_size)
     self.aggregator_cls = MeanAggregator
     self.aggregator = self.aggregator_cls(self.memory_word_size,
                                           self.memory_word_size,
                                           name="aggregator",
                                           concat=False)
     # 根据当前状态得到读取索引,用到相似度度量
     self._read_content_similarity = utils.CosineSimilarity(
         1, word_size=memory_word_size, name="read_content_similarity")
     # 策略输出
     self.epsilon = 0.9
     self.num_actions = num_actions
     self._optimizer = tf.keras.optimizers.Adam(learning_rate=1e-3)
コード例 #4
0
ファイル: MemReadWrite.py プロジェクト: kangyongxin/GBMRcode
 def __init__(self, memory_word_size,memory_size,name='MemWriter'):
     self._memory_word_size = memory_word_size
     self._write_content_similarity = utils.CosineSimilarity(1,memory_word_size,name="write_content_similarity")
     #应该把Gmemory继承过来做内部值,不然每个函数都要用一下
     self._TH =0.999 #计算阈值,如果大于这个值新建节点(余弦距离的时候有正有负,所以暂时取正的)