0
교육 강화 학습 에이전트 :tflearn 손실은 항상 0.0입니다 동안 나는이 코드를 사용하여 체육관과 tflearn와 에이전트를 학습 강화 훈련을 시도
가from tflearn import *
import gym
import numpy as np
env = gym.make('CartPole-v0')
x = []
y = []
max_reward = 0
for i in range(1000):
env.reset()
while True:
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
break
if reward >= max_reward:
x.append(observation)
y.append(np.array([action]))
x = np.asarray(x)
y = np.asarray(y)
net = input_data((None,4))
net = fully_connected(net,8,'softmax')
net = fully_connected(net,16,'softmax')
net = fully_connected(net,32,'softmax')
net = fully_connected(net,64,'softmax')
net = fully_connected(net,128,'softmax')
net = fully_connected(net,64,'softmax')
net = fully_connected(net,32,'softmax')
net = fully_connected(net,16,'softmax')
net = fully_connected(net,8,'softmax')
net = fully_connected(net,4,'softmax')
net = fully_connected(net,2,'softmax')
net = fully_connected(net,1)
net = regression(net,optimizer='adam',learning_rate=0.01,loss='categorical_crossentropy',batch_size=1)
model = DNN(net)
model.fit(x,y,10)
model.save('saved/model.tflearn')
문제는, 모델이 손실을 훈련 할 때 항상 0.0
입니다을 . 누군가가이 호를 도울 수 있습니까? 당신이 손실 0
을 받고 왜 당신의 목표는 무엇입니까하지만 categorical_crossentropy
는 멀티 클래스 분류에 사용되는 손실 함수이지만, 네트워크의 출력이 선형 활성화에 하나 개의 단위 fully_connected(net,1)
입니다
왜 'softmax' 레이어가 너무 많습니까?'sigmoid' 또는'relu'를 사용하셨습니까? –
사실 그것은 의도적이었습니다. 하지만 전적으로 초보자를 배우는 기계이기 때문에 실수 일 수 있습니다. –