LSTM with 12 input and output nodes with no embedding
Question: all I need is a RNN LSTM with 12 input nodes, 12 output nodes and have ability
to tweak hidden layers (their number and size).

The elements of input and output vectors can be real numbers or integers (I
have integers on input). Is it necessary to use one hot encoding here (because
it would be unusable with so many combinations)? I thought that this layer is
redundant, since my inputs are already vectors.

I couldn't build this neural network with Python (Lasagne, Block, Keras...)
nor Torch.

The closest I've got so far is with Pybrain, but this package is in
"maintance" mode (only bug fixes), is terribly slow (it's not built on Theano)
and supports only one LSTM layer, which is insufficient. But at least it does
what I want - it takes one vector of 12 numbers and returns another vector of
12 numbers.

Here is an example using pybrain:

    
    
    # Preparing data
    from pybrain.datasets import SequentialDataSet
    from itertools import cycle
    
    sp = 4000
    data = np.random.randint(1,100,(5000,12))
    def splt_seq(data):
        sq = SequentialDataSet(12, 12)
        for sample, next_sample in zip(data, cycle(data[1:])):
            sq.addSample(sample, next_sample)
        return(sq)
    
    train = splt_seq(data[:sp])
    test = splt_seq(data[sp:sp+200])
    
    
    # Building network and training
    from pybrain.tools.shortcuts import buildNetwork
    from pybrain.structure.modules import LSTMLayer
    
    net = buildNetwork(12, 100, 12,
               hiddenclass=LSTMLayer, outputbias=False, recurrent=True)
    
    from pybrain.supervised import RPropMinusTrainer
    from sys import stdout
    
    trainer = RPropMinusTrainer(net, dataset=train)
    train_errors = [] # save errors for plotting later
    EPOCHS_PER_CYCLE = 5
    CYCLES = 100
    EPOCHS = EPOCHS_PER_CYCLE * CYCLES
    for i in range(CYCLES):
        trainer.trainEpochs(EPOCHS_PER_CYCLE)
        train_errors.append(trainer.testOnData())
        epoch = (i+1) * EPOCHS_PER_CYCLE
        print("\r epoch {}/{}".format(epoch, EPOCHS), end="")
        stdout.flush()
    
    print()
    print("final error =", train_errors[-1])
    
    net.activate(X_test.getSample()[0])
    

With keras I haven't got to far, as can be seen
[here](https://groups.google.com/forum/#!topic/keras-users/-L4k2VQ0GXk)


Answer: It depends. You did not specify the details of your input, other than its
length and type. Are the elements of your input vector discrete or continuous?
If they are discrete, you must one-hot encode your vector. Else you could feed
your data directly to your RNN-LSTM.

Difference between discrete and continuous:

Suppose your vector contains information regarding 12 cards that were randomly
picked from a deck of cards. You might have indexed your cards from 0 to 51
(52 cards in a deck) and your input vector would look like this:

[3,4,17,50,20,10,11,36,5,0,23,49]

Now you have a problem, the indices of each card do not represent any
quantitative measure of the cards (card 50 is not 5 times more 'something'
than card 10). So you have to one hot encode the vectors, so that the cards
would dwell in a larger space, equidistant from each other:
[e(3,52),e(4,52),e(17,52)......e(23,52)]

If your input contains continuous data like weather information,(each of the
12 elements being different factors like temperature,wind,humidity, etc), one
hot encoding it would not make any sense. Just input the vector to your RNN-
LSTM as is.

As you have mentioned that the input could also be real numbers, its more
probable that your input is continuous and need not be one hot encoded. Hope
that helps!

