title: k-fold cross validation using tensorflow
body: <p>I have created an artificial neural network. I am trying to calculate the accuracy of the model using k-fold cross validation technique but after compiling the last line its not progressing any further, its stuck there for more than 20 mins. I am not able to figure out where I am going wrong. Can anyone please help me with this thing? Below is the code I have used.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import pandas as pd
  
  dataset = pd.read_csv('Churn_Modelling.csv')
  X = dataset.iloc[:, 3:13].values
  y = dataset.iloc[:, 13].values
  
  from sklearn.preprocessing import LabelEncoder, OneHotEncoder
  labelencoder_X_1 = LabelEncoder()
  X[:, 1] = labelencoder_X_1.fit_transform(X[:, 1])
  labelencoder_X_2 = LabelEncoder()
  X[:, 2] = labelencoder_X_2.fit_transform(X[:, 2])
  onehotencoder = OneHotEncoder(categorical_features = [1])
  X = onehotencoder.fit_transform(X).toarray()
  X=X[:,1:]
  
  from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
  
  from sklearn.preprocessing import StandardScaler
  sc = StandardScaler()
  X_train = sc.fit_transform(X_train)
  X_test = sc.transform(X_test)
  
  from keras.wrappers.scikit_learn import KerasClassifier
  from sklearn.model_selection import cross_val_score
  from keras.models import Sequential #required to initialize ann
  from keras.layers import Dense #required to build the layers of ann
  
  def build_classifier():
      classifier=Sequential()
      classifier.add(Dense(kernel_initializer="uniform", activation="relu", input_dim=11, units=6))
      classifier.add(Dense(kernel_initializer="uniform", activation="relu", units=6))
      classifier.add(Dense(kernel_initializer="uniform", activation="sigmoid",units=1))
      classifier.compile(optimizer='adam', loss='binary_crossentropy',metrics=['accuracy'])
      return classifier
  classifier=KerasClassifier(build_fn=build_classifier, batch_size=10, nb_epoch=100)
  accuracies=cross_val_score(estimator=classifier,X=X_train,y=y_train,cv=10,n_jobs=-1)
  </code></pre>