10
$\begingroup$

I want to train a neural network with a sequence of character as an input vector. Learning examples have different length and for this reason I don't know how to represent them.

Let's say I have two examples of sequences, here names:

john doe
maurice delanoe

First example is of length 8, second is of length 15.

Is there a way to learn of both these examples ? Meaning to use both an input vector of size 8 and 15 in the same learning system.

Thanks for your help !

$\endgroup$

1 Answer 1

5
$\begingroup$

There are three general strategies I can think of for NNs with varying input sizes:

  1. Preprocess the inputs to save the same size. For example, people often resize images (ignoring aspect ratio) to a standard square resolution for NNs. In the language case, you might convert all words to a symbolic representation (e.g. "john"=1, "james"=2, "maurice"=3, "kelly"=4, "doe"=5) if that makes sense in your application.
  2. Use a sliding window. The network gets to see a fixed-size portion of the input, and then you slide the window by some fixed stride and run it again (from scratch), repeat until you hit the end, and then combine all the outputs in some way.
  3. Same as #2, but using a recurrent neural network so that the network has some internal state that carries over between each stride. This is how NNs process speech audio, for example. Obviously this is a more dramatic change to the architecture than the other options, but for many language tasks this might be necessary (if you have long inputs and need to combine information across the string in a complicated way).
$\endgroup$

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.