Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

python - Keras, Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'numpy.float64'>

def DQN(height, width):
    model = keras.models.Sequential([
        keras.layers.Input(shape = (height*width*3)),
        keras.layers.Dense(100, activation = "relu", kernel_initializer='he_uniform'),
        keras.layers.Dense(50, activation = "relu", kernel_initializer='he_uniform'),
        keras.layers.Dense(25, activation = "relu", kernel_initializer='he_uniform'),
        keras.layers.Dense(2, activation = "softmax", kernel_initializer='he_uniform')
    ])
    return model

policy_net = DQN(180, 360)
policy_net.compile(optimizer = 'Adam', loss = 'mse')

policy_net.fit(states[batch].reshape(1, 194400), target_q_values, epochs = 1)

and this error raised: ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'numpy.float64'>

print("target_q_values :  ", target_q_values)
1.5188535671234131

print("states[batch] : ", states[batch])
states[batch] :  [[0. 0. 0. ... 0. 0. 0.]]

print("target_q_values :  ", target_q_values.dtype)
print("states[batch] : ", states[batch].reshape(1, 194400).dtype)
target_q_values :   float64
states[batch] :  float64

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share

1.2m questions

2.1m answers

5 comments

56.5k users

...