У меня проблема при попытке подачи заполнителей, с feed_dict = {..} в функции train_epoch, он не распознает заполнители
Вот код ..
class CNN(object):
###......
def define_train_opeartions(self):
X_data_train = tf.placeholder(dtype=tf.float32, shape=(None, self.height,self.width,self.chan),name='X_data_train')
Y_data_train = tf.placeholder(dtype=tf.int32, shape=(None, self.n_classes),name='Y_data_train') # Define this
# Network prediction
Y_net_train = self.inference(
X_data_train,reuse=False)
# Loss of train data tf.nn.softmax_cross_entropy_with_logits
self.train_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(labels=Y_data_train, logits=Y_net_train, name='train_loss'))
# define learning rate decay method
global_step = tf.Variable(0, trainable=False, name='global_step')
# Define it--play with this
learning_rate = 0.001
# define the optimization algorithm
# Define it --shall we try different type of optimizers
optimizer = tf.train.AdamOptimizer(learning_rate)
trainable = tf.trainable_variables() # may be the weights??
self.update_ops = optimizer.minimize(
self.train_loss, var_list=trainable, global_step=global_step)
# --- Validation computations
X_data_valid = tf.placeholder(dtype=tf.float32, shape=(None, self.height, self.width, self.chan)) # Define this
Y_data_valid = tf.placeholder(dtype=tf.int32, shape=(None, self.n_classes)) # Define this
# Network prediction
Y_net_valid = self.inference(X_data_valid,reuse=True)
# Loss of validation data
self.valid_loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits_v2(
labels=Y_data_valid, logits=Y_net_valid, name='valid_loss'))
А потом у меня есть другая функция
def train_epoch(self, sess):
train_loss = 0
total_batches = 0
keep_probability=0.2 #dropout probability
n_batches = self.train_size / self.batch_size # ??
indx=0
while (total_batches < n_batches): # loop through train batches:
X,Y=self.shuffling(self.Xtrain_in,self.Ytrain_in) # shuffle X ,Y data
Xbatch,Ybatch,indx=self.read_nxt_batch(X,Y,self.batch_size,indx) # take the right batch
mean_loss, _ = sess.run([self.train_loss, self.update_ops], feed_dict={X_data_train: Xbatch ,Y_data_train: Ybatch })
if math.isnan(mean_loss):
print('train cost is NaN')
break
train_loss += mean_loss
total_batches += 1
if total_batches > 0:
train_loss /= total_batches
return train_loss
Сообщение об ошибке: Ошибка типа: Невозможно интерпретировать ключ feed_dict как Tensor: Имя> 'X_data_train' относится к операции, а не к тензору.Тензорные имена должны иметь форму op_name: output_index.