1

I am implementing a kind of Neural Network, in particular a Multilayer Perceptron to detect the language of the several sentences. In particular, I am using Tensorflow in Python 3.X.

Previously, I have built a 2-gram file from several sentences in 10 languages. 2-gram file is using as input of my Neural Network. For example, a sentences like "I like footbal" could be ['1','15','3',...,'30'].

As tutorial, I am following the next.

That example is using MINST as you can see at import section:

from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)

My question is, how can I pass this vector to my Neural Network?

In the example, I can see the following statement:

batch_x, batch_y = mnist.train.next_batch(batch_size)

And, this other one:

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

There, it is difficult to understand because I can not know which is the type of batch_x and batch_y.

1 Answer 1

1

They can be in numpy or list format, but when you feed it with feed_dict, it turns to tensor object,

You can pass it by feed_dict, as sess.run([optimizer, cost], feed_dict={x: batch_x, y: batch_y})

Generally, you have data x and labels y and you want to train your network with x and calculate loss(or cost) based on y, now for training, you no need to feed whole x to network, but instead, we divide x to parts which called batch then, pick each batch and train the network (so each batch has batch_x for data and batch_y for labels), then go to next batch.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help. I understood that I have to get each sentences like integer vector (batch), and batch_x has all sentences like integer vector. I am going to use python list type of integers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.