title: InvalidArgumentError: input_1:0 is both fed and fetched, error with tensorflow, python
body: <p>I am trying to run a code that tells me number of fall and non fall in fall detection of a human and i am getting an error :</p>
  
  <blockquote>
    <p>input_1:0 is both fed and fetch . </p>
  </blockquote>
  
  <p>I tried running it alone but never works. </p>
  
  <pre><code>from keras.models import Model
  from keras.utils import np_utils
  import numpy as np
  import pandas as pd
  import os
  os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
  import scipy.io as sio
  import matplotlib.pyplot as plt
  import keras 
  from keras.callbacks import ReduceLROnPlateau
  from keras.layers.core import Flatten, Dense, Dropout, Lambda
  from keras import backend as K
  import cv2
  def global_average_pooling(x):
  return K.mean(x, axis = (2))
  def global_average_pooling_shape(input_shape):
  return input_shape[0:2]
  p=Lambda(global_average_pooling, 
  output_shape=global_average_pooling_shape)
  X = sio.loadmat('/Users/fateh/Documents/Hamidreza Work/ConvFall/ts.mat')
  X=X['Data']
  import csv
  with open('/Users/fateh/Documents/Hamidreza Work/ConvFall/lab.csv', 'r') as mf:
       re = csv.reader(mf,delimiter=',',quotechar='|')
       re=np.array(list(re))
       label = re.astype(np.float64)
       Y_t=np.squeeze(label) 
  nb_epochs = 3
  y_train =Y_t[:158]
  y_test =Y_t[158:]
  x_train=X[:158]
  x_test=X[158:]
  nb_classes = len(np.unique(y_test))
  batch_size = min(x_train.shape[0]/8, 16)
  y_train = (y_train - y_train.min())/(y_train.max()-y_train.min())*(nb_classes-1)
  y_test = (y_test - y_test.min())/(y_test.max()-y_test.min())*(nb_classes-1)
  Y_train = np_utils.to_categorical(y_train, nb_classes)
  Y_test = np_utils.to_categorical(y_test, nb_classes)
  x_train_mean = x_train.mean()
  x_train_std = x_train.std()
  x_train = (x_train - x_train_mean)/(x_train_std) 
  x_test = (x_test - x_train_mean)/(x_train_std)
  x_train = x_train.reshape(x_train.shape + (1,))
  x_test = x_test.reshape(x_test.shape + (1,))
  #x_train = np.transpose(x_train, (0, 2, 1))
  #x_test = np.transpose(x_test, (0, 2, 1))
  input_shape=x_train.shape[1:]
  x = keras.layers.Input(x_train.shape[1:])
  #    drop_out = Dropout(0.2)(x)
  conv1 = keras.layers.Convolution1D(300, 9, padding='same')(x)
  conv1 = keras.layers.normalization.BatchNormalization()(conv1)
  conv1 = keras.layers.Activation('relu')(conv1)
  conv2 = keras.layers.Convolution1D(200, 5, padding='same')(conv1)
  conv2 = keras.layers.normalization.BatchNormalization()(conv2)
  conv2 = keras.layers.Activation('relu')(conv2)
  conv3 = keras.layers.Convolution1D(100, 3, padding='same')(conv2)
  conv3 = keras.layers.normalization.BatchNormalization()(conv3)
  conv3 = keras.layers.Activation('relu')(conv3)
  full = p(conv3)    
  out = keras.layers.Dense(nb_classes, activation='softmax')(full)
  model = Model(input=x, output=out)
  optimizer = keras.optimizers.Adam() #'sgd'
  model.compile(loss='categorical_crossentropy',
                optimizer=optimizer,
                metrics=['accuracy'])
  reduce_lr = ReduceLROnPlateau(monitor = 'loss', factor=0.5,
                    patience=500, min_lr=0.001) 
  hist = model.fit(x_train, Y_train, batch_size=batch_size, epochs=nb_epochs,
            verbose=1, validation_data=(x_test, Y_test), callbacks = [reduce_lr])
  predict = model.predict(x_test)
  preds = np.argmax(predict, axis=1)
  log = pd.DataFrame(hist.history)
  print(log.loc[log['loss'].idxmin]['loss'], log.loc[log['loss'].idxmin]['val_acc'])
  labels = {1:'Non-Fall', 2:'Fall'}
  from sklearn.metrics import classification_report, confusion_matrix
  print(classification_report(preds, y_test,
                              target_names=[l for l in labels.values()]))
  conf_mat = confusion_matrix(preds, y_test)
  fig = plt.figure(figsize=(2,2))
  res = plt.imshow(np.array(conf_mat), cmap=plt.cm.summer, interpolation='nearest')
  for i, row in enumerate(conf_mat):
      for j, c in enumerate(row):
          if c&gt;0:
              plt.text(j-.2, i+.1, c, fontsize=16)
  #cb = fig.colorbar(res)
  plt.title('Confusion Matrix')
  _ = plt.xticks(range(2), [l for l in labels.values()], rotation=90)
  _ = plt.yticks(range(2), [l for l in labels.values()])
  inp = model.input                                           # input placeholder
  outputs = [layer.output for layer in model.layers]          # all layer outputs
  functor = K.function([inp]+ [K.learning_phase()], outputs ) # evaluation function
  
  # Testing
  test=x_test[2:3,:,:]
  test = np.random.random(input_shape)[np.newaxis,:]
  layer_outs = functor([test, 1.])
  </code></pre>
  
  <p>Trying to run this code used for letting you know the fall detection of files through deep Convolutional Neural Network, where radar data is used to collect raw data and processed. </p>