Пример #1
0
        shape = (x[0], ) + shape
    return shape


lstm = Function.lstm(real=True,
                     integer=None,
                     eval=lstm_recursive,
                     shape=property(shape))


def LSTM(x, *weights):
    (W, ), (Wh, ), (b, ) = weights
    n = x.shape[0]
    t = Symbol.t(integer=True)
    return Lamda[t:n](Indexed(lstm[W, Wh, b, t](x), 0))


def LSTMCell(x, *weights):
    (W, ), (Wh, ), (b, ) = weights
    n = x.shape[0]
    t = Symbol.t(integer=True)
    return Lamda[t:n](Indexed(lstm[W, Wh, b, t](x), 1))


LSTM = Function.LSTM(real=True, integer=None, eval=LSTM, shape=property(shape))

LSTMCell = Function.LSTMCell(real=True,
                             integer=None,
                             eval=LSTMCell,
                             shape=property(shape))