Trainining the dataset by batch TypeError cannot convert the series to type int

by: Madhivarman, 7 years ago

Last edited: 7 years ago

Hello all , I am trying to train a model to detect credit card fraud transaction . I have a large dataset and  i want to train the dataset by batches.First I converted all dataset value into numpy arrays .
[training_set = np.float32(FILENAME.VALUES)][/cdde]
and i initially declared epochs and batch size
[hm_epochs = 100
batch_size = 500]</pre>
And while training the data by the batches i get an error. My code is
[
   def TrainNeuralNetwork(x):

prediction = NeuralNetworkModel(x)
#cost function
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=prediction,labels=y))
#optimizer
optimizer = tf.train.AdamOptimizer().minimize(cost)

#how many epochs ?
hm_epochs = 100

#start the session

with tf.Session() as sess:
#run the session
sess.run(tf.global_variables_initializer())

for epochs in xrange(hm_epochs):

epoch_loss = 0
#loop over all batches
for batches in xrange(int(TRAINING_SHAPE[0] / batch_size)):

epoch_x, epoch_y = training_data[:batches,:]

_ , c = sess.run([optimizer,cost],feed_dict = {x:epoch_x,y:epoch_y})

epoch_loss  += c

print('Epoch:',epochs , 'Completed out of:',hm_epochs , 'loss:',epoch_loss)

correct = tf.equal(tf.argmax(prediction,1),tf.argmax(y,1))

accuracy = tf.reduce_mean(tf.cast(correct,'float'))

print("Accuracy of training is:%2f",(accuracy * 100))

TrainNeuralNetwork(x)

]</pre>
And the error  is
[
   Traceback (most recent call last):
  File "train.py", line 114, in <module>
    TrainNeuralNetwork(x)
  File "train.py", line 92, in TrainNeuralNetwork
    for batches in xrange(int(TRAINING_SHAPE[0] / batch_size)):
  File "/root/.local/lib/python2.7/site-packages/pandas/core/series.py", line 112, in wrapper
    "{0}".format(str(converter)))
TypeError: cannot convert the series to <type 'int'>
]</pre>

TRAINING_SHAPE[0].shape is nothing number of rows in the dataset .
Thanks ..!



You must be logged in to post. Please login or register an account.