0
私はゲーム入力で神経ネットワークを鍛えようとしています.GTA 5のバイクはモデルによって駆動されています。画面フレームを入力として受け取り、トレーニング中に入力したキーを記録します。コードが機能しない:電車にalexnetモデルを試してみよう
このエラーメッセージが常に表示されていて、修正方法を見つけることができません。
>Traceback (most recent call last):
File "training_model.py", line 27, in <module>
show_metric =True, run_id = MODEL_NAME)
File "C:\Users\Aman\Anaconda2\envs\tensorflow\lib\site-packages\tflearn\models\dnn.py", line 184, in fit
self.targets)
File "C:\Users\Aman\Anaconda2\envs\tensorflow\lib\site-packages\tflearn\utils.py", line 331, in feed_dict_builder
"such variable is known to exist" % key)
Exception: Feed dict asks for variable named 'target' but no such variable is known to exist
コードモデルを訓練するために:
ここでエラーメッセージです
import numpy as np
from alexnet import alexnet
WIDTH = 80
HEIGHT = 60
EPOCHS = 2
LR = 1e-3
MODEL_NAME = 'pygta5-car-{}-{}-{}-epochs.model'.format(LR, 'alexnetv2', EPOCHS)
model = alexnet(WIDTH, HEIGHT, LR)
train_data = np.load('final_data.npy', encoding = 'bytes')
train_dataset = train_data[:-400]
test_dataset = train_data[-400:]
X = np.array([i[0] for i in train_dataset]).reshape(-1, WIDTH, HEIGHT, 1)
Y = [i[1] for i in train_dataset]
test_x = np.array([i[0] for i in test_dataset]).reshape(-1, WIDTH, HEIGHT, 1)
test_y = [i[1] for i in test_dataset]
model.fit({'input' : X}, {'target' :Y}, n_epoch = EPOCHS, validation_set =
({'input' :test_x}, {'target' :test_y}), snapshot_step = 300,
show_metric =True, run_id = MODEL_NAME)
model.save(MODEL_NAME)
Alexnetモデル:
#alexnet.py
import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
from tflearn.layers.normalization import local_response_normalization
def alexnet(width, height, lr):
network = input_data(shape=[None, width, height, 1], name='input')
network = conv_2d(network, 96, 11, strides=4, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 3, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=2, tensorboard_dir='log')
return model
ありがとうございました! –