D
D
Denis Goncharenko2019-10-20 09:26:01
Neural networks
Denis Goncharenko, 2019-10-20 09:26:01

What to apply to the input of the neuron?

In the case of processing an image by a neuron, everything is clear, an image of a fixed size is taken there and pixel values ​​​​are fed to the input of the neuron. But what if the number of input data can vary? For example, if a neuron needs to make some conclusion about a word, then the letters of this word will probably be input, but there may be a different number of them.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
longclaps, 2019-10-20
@longclaps

Consider words of length up to 10 letters inclusive. The least common multiple of the lengths is 2520, which is probably acceptable.
You take and feed to the inputs:
"a" -> "a" * 2520
"ab" -> "a" * 1260 + "b" * 1260
and so on.
p.s. I haven't tried it myself.
pps I just showed how "scaling" can be implemented. But what prevents you from simply filling up the word to the maximum length with spaces? Probably a lack of intelligence and ingenuity) You can come up with many ways.

D
Danil, 2019-10-20
@DanilBaibak

Sample action plan:
In this way, the dimensions of the input data can be solved. An example for clarity:

import numpy as np

from tensorflow.keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences

X = np.array(['диверсификация', 'приз', 'калейдоскоп'])

tokenizer = Tokenizer(char_level=True)
tokenizer.fit_on_texts(X)

X_tokenized = tokenizer.texts_to_sequences(X)
print(X_tokenized)

X_padded = pad_sequences(X_tokenized, maxlen=len(X_tokenized[2]), padding='post', truncating='post')
print(X_padded)

M
mayton2019, 2019-10-21
@mayton2019

There can be a million roads, depending on what the author wants to get at the output.
If - count the number of vowels - then one thing. If you categorize a word or words,
then it is different. And maybe some word processing is needed here. Stemming or lemmatization.
In general, the NN receives vectors of real numbers as input. And converting the word into these vectors is a great art. It must be meaningful. If we failed to get these vectors, then it is useless to do anything. The neuron at the input will see the noise. And no generalization can be made.
Therefore, let's ask in the topic what does the real terms of reference sound like?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question