# How to do give input to CNN when doing a text processing?

As a signal processing engineering and being new to NLP, I am confused with giving input to CNN network.

With my knowledge of CNN, I am trying to build a classifier for ethnicity with inputs as text (last name(LN), middle name(MN), first name(FN)). I have a list of 8,000,000 samples with last, middle, first names and class information

array = [['person1_LN','person1_MN','person1_FN','Person1_class'],
['person1_LN','person1_MN','person1_FN','Person2_class'],
....]


I want to apply conv layer (CL) followed by Pooling Layer(PL) on LN,MN,FN respectively.

Text processing example demonstrates with the sentences to convert to word embedding. I am trying to understand this code snippet

W = tf.Variable(tf.random_uniform([vocab_size, embedding_size], -1.0, 1.0), name='W')
self.embedded_chars = tf.nn.embedding_lookup(W, self.input_x)
self.embedded_chars_expanded = tf.expand_dims(self.embedded_chars, -1)


This tutorial says training to be done using word2vec. Reading these two blogs I could understand nothing. In Either of the cases, my data is not a sentence, moreover in the second case on what things I have to train?

Will the CL operate if I directly give the input of words without word embeddings? If not any example on how to embed the words in my case to give the input to CNN?

• Are you familiar with Conv1D? – Media Apr 12 '18 at 14:28
• I have applied 1D CNN to signals, I am stuck on how to apply text to CNN. – Raady Apr 13 '18 at 10:56