Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Machine learning 无法将NumPy数组转换为张量?_Machine Learning_Lstm_Recurrent Neural Network - Fatal编程技术网

Machine learning 无法将NumPy数组转换为张量?

Machine learning 无法将NumPy数组转换为张量?,machine-learning,lstm,recurrent-neural-network,Machine Learning,Lstm,Recurrent Neural Network,我正在尝试创建一个使用LSTM进行交易的代理,但是我遇到了一些冲突 def batch_train(self, batch_size): batch = [] for i in range(len(self.memory) - batch_size + 1, len(self.memory)): batch.append(self.memory[i]) for state, action, reward, next_state, done in batch: if

我正在尝试创建一个使用LSTM进行交易的代理,但是我遇到了一些冲突

def batch_train(self, batch_size):
   batch = []
   for i in range(len(self.memory) - batch_size + 1, len(self.memory)):
      batch.append(self.memory[i])

for state, action, reward, next_state, done in batch:
  if not done:
    reward = reward + self.gamma * np.amax(self.model.predict(next_state)[0])
    
  target = self.model.predict(state)
  target[0][action] = reward
  
  self.model.fit(state, target, epochs=1, verbose=0)
  
if self.epsilon > self.epsilon_final:
  self.epsilon *= self.epsilon_decay
这里调用函数 ValueError:无法将NumPy数组转换为张量(不支持) 对象类型numpy.ndarray)


你的数组是布尔型的吗?如果尚未将其转换为float32,请尝试将其转换为float32

X = np.asarray(X).astype(np.float32)

你的数组是布尔型的吗?如果尚未将其转换为float32,请尝试将其转换为float32

X = np.asarray(X).astype(np.float32)

要使问题重现,您应该为us trade.memory和batch_size申报。要使问题重现,您应该为us trade.memory和batch_size申报