3
$\begingroup$

I want to build neural network, where my input will be a word(not a sentence). My set of words has many words with different lenght (number of chars). My idea to do it is transform chars to numbers using predefine dictionary, next use it as input. Number of neurons in input layer set as a number of chars in a longest word in my set. In vectors witch are shorter I'll fill them by zero.

My set of words looks that:

1. head
2. hello
3. butterfly
4. hotel
5. fly
6. spy

So for this set my input to netowrk should has 9 neurons. When I transform 'head', I will get vector with 4 numbers and 5 zeros.

It's a good idea? Or maybe you have another better idea how input of this network could look.

EDIT:

My task is described here: ML model to transform words: And I want to build GAN as an answer suggest. So this words will be my 'real words' and I want to generate fake words.

$\endgroup$
2
  • $\begingroup$ Can you tell what is your task? Depending on that, people can tell you different approaches. The information you gave is not enough to suggest anything. $\endgroup$
    – Ankit Seth
    Jun 13, 2018 at 12:14
  • $\begingroup$ @AnkitSeth I added edit with explanation my task $\endgroup$ Jun 13, 2018 at 12:33

2 Answers 2

1
$\begingroup$

The simple way here is to make a one-hot over letters. So you will have many columns with ones and zeros. This may now be an input layer for your nn.

$\endgroup$
0
$\begingroup$

While your approach sounds logical, it is quite different from how most language-based models are created. You really need to tell us what it is that your want your model to learn and be able to predict, once you have trained it. Why are you interested in the length of the words; what is the significance of the input layer having the same number of neurons as there are characters in your longest word? It sounds like a performance optimisation of some kind.

Because we are usually interested in the meanings of words, methods have been developed which encode meanings. There are models such as Word2Vec, which take text as input and produce a semantic meaning for each word in the form of a vector. See a tutorial here.

When we have images as inputs to a model, we are usually interested in things like as "what is in the picture?", "where in the picture is it?" and "what is next to what?". This means that spatial information is important.

Word vectors and images are both then in numerical form and can be passed into a network. We still need to to know what we want our model to learn, as to know what we want to optimise; we must decide on a definition for loss or error, as this is what then trains the model via backpropagation.

$\endgroup$
1
  • $\begingroup$ I added edit with explanation my task $\endgroup$ Jun 13, 2018 at 12:33

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.