出ているエラー
train_on_batch でエラーがでる
試したこと
エラーの原因を探したのですがとくに見当たらず
kerasのfit もしくはtrain_on_batch の教師データはflort型ではだめなのですか?
NAFという連続値の出力の強化学習を試してます
インプットは画像データ 4004003
下のmodelのアウトプット(net_q) 1
教師データのtypeはnumpy.ndarray
for i, (state_b, action_b, reward_b, next_state_b) in enumerate(batch_memory.buffer): inputs[i:i + 1] = [state_b,action_b]#------------ target=reward_b+gamma*targetQN.net_v.train_on_batch(next_state_b)[0] targets[i] = target # 教師信号 self.net_q.train_on_batch(inputs, targets)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-1-ef54f3625b95> in <module> 358 memory_TDerror.update_TDerror(memory, gamma, mainQN, targetQN,multireward_steps) 359 for _ in range(t): --> 360 mainQN.pioritized_experience_replay(memory, batch_size, gamma, targetQN, memory_TDerror, state_size=state_, action_size=action_size) 361 targetQN = mainQN # 行動決定と価値計算をおなじにする 362 <ipython-input-1-ef54f3625b95> in pioritized_experience_replay(self, memory, batch_size, gamma, targetQN, memory_TDerror, state_size, action_size) 247 targets[i] = target # 教師信号 248 print(targets[i]) --> 249 self.net_q.train_on_batch(inputs, targets) 250 #memoriiiiiiiiiiiiiiiiiiiiiiiiii---------------------------------------------------------------------------- 251 class Memory: c:\users\pc_user\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\training.py in train_on_batch(self, x, y, sample_weight, class_weight, reset_metrics) 1506 x, y, 1507 sample_weight=sample_weight, -> 1508 class_weight=class_weight) 1509 if self._uses_dynamic_learning_phase(): 1510 ins = x + y + sample_weights + [1] c:\users\pc_user\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_array_lengths, batch_size) 577 feed_input_shapes, 578 check_batch_axis=False, # Don't enforce the batch size. --> 579 exception_prefix='input') 580 581 if y is not None: c:\users\pc_user\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\training_utils.py in standardize_input_data(data, names, shapes, check_batch_axis, exception_prefix) 97 data = data.values if data.__class__.__name__ == 'DataFrame' else data 98 data = [data] ---> 99 data = [standardize_single_array(x) for x in data] 100 101 if len(data) != len(names): c:\users\pc_user\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\training_utils.py in <listcomp>(.0) 97 data = data.values if data.__class__.__name__ == 'DataFrame' else data 98 data = [data] ---> 99 data = [standardize_single_array(x) for x in data] 100 101 if len(data) != len(names): c:\users\pc_user\anaconda3\envs\ml-agents\lib\site-packages\keras\engine\training_utils.py in standardize_single_array(x) 32 'Got tensor with shape: %s' % str(shape)) 33 return x ---> 34 elif x.ndim == 1: 35 x = np.expand_dims(x, 1) 36 return x AttributeError: 'list' object has no attribute 'ndim'
回答1件
あなたの回答
tips
プレビュー