Giter VIP home page Giter VIP logo

Comments (4)

farizrahman4u avatar farizrahman4u commented on August 22, 2024

See my last answer at : keras-team/keras#2968

By the way, thanks for this wonderful peace of software, which Keras lacks so much.

You are welcome!

from recurrentshop.

farizrahman4u avatar farizrahman4u commented on August 22, 2024

Also checkout docs/readout.md

from recurrentshop.

msurtsukov avatar msurtsukov commented on August 22, 2024

I've just tried code from docs/readout.md

x = Input((10,))
h_tm1 = Input((10,))
c_tm1 = Input((10,))
readout_input = Input((10,))


# Here, I simply add half the readout to the input.. you can do whatever you want.

readout_half = Lambda(lambda x: 0.5 * x)(readout_input)
lstms_input = add([x, readout_half])

# Deep LSTM
depth = 3

cells = [LSTMCell(10) for _ in range(depth)]

lstms_output, h, c = lstms_input, h_tm1, c_tm1


for cell in cells:
    lstms_output, h, c = cell([lstms_output, h, c])

y = lstms_output

rnn = RecurrentModel(input=x, initial_states=[h_tm1, c_tm1], output=y, final_states=[h, c], readout_input=readout_input)

and ran into an error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-29-28879aa4ed9a> in <module>()
     23 y = lstms_output
     24 
---> 25 rnn = RecurrentModel(input=x, initial_states=[h_tm1, c_tm1], output=y, final_states=[h, c], readout_input=readout_input)

/Users/mikhail/anaconda/lib/python3.6/site-packages/recurrentshop-1.0.0-py3.6.egg/recurrentshop/engine.py in __init__(self, input, output, initial_states, final_states, readout_input, teacher_force, decode, output_length, return_states, **kwargs)
    281             raise Exception('Readout should be enabled for teacher forcing.')
    282         self.teacher_force = teacher_force
--> 283         self.model = Model(inputs, outputs)
    284         super(RecurrentModel, self).__init__(**kwargs)
    285         input_shape = list(K.int_shape(input))

/Users/mikhail/anaconda/lib/python3.6/site-packages/keras/legacy/interfaces.py in wrapper(*args, **kwargs)
     86                 warnings.warn('Update your `' + object_name +
     87                               '` call to the Keras 2 API: ' + signature, stacklevel=2)
---> 88             return func(*args, **kwargs)
     89         wrapper._legacy_support_signature = inspect.getargspec(func)
     90         return wrapper

/Users/mikhail/anaconda/lib/python3.6/site-packages/keras/engine/topology.py in __init__(self, inputs, outputs, name)
   1702                                 'The following previous layers '
   1703                                 'were accessed without issue: ' +
-> 1704                                 str(layers_with_complete_input))
   1705                     for x in node.output_tensors:
   1706                         computable_tensors.append(x)

RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor("input_4:0", shape=(?, 10), dtype=float32) at layer "input_4". The following previous layers were accessed without issue: []

There are also some typos in docs: LSTM instead of LSTMCell and an issue with Lambda layer.

Also when using decode=True and setting output_length isn't it doing something like

cells = [LSTMCell(10) for _ in range(depth)]
lstms_output, h, c = lstms_input, h_tm1, c_tm1
for cell in cells:
    lstms_output, h, c = cell([lstms_output, h, c])

internally?

And could you, please, show how to run this rnn layer in the graph, I mean should it be done like this?

rnn(input, initial_states=[x], readout_input=readout)

Sorry for being annoying.

from recurrentshop.

farizrahman4u avatar farizrahman4u commented on August 22, 2024

and ran into an error:

Should be fixed now.

Also when using decode=True and setting output_length isn't it doing something like ... internally?

Sorry.. I don't get you.. can you elaborate??

And could you, please, show how to run this rnn layer in the graph

You use it like a regular Keras Recurrent layer.

y = rnn(x)

You can also provide initial states (default is zeros):

y = rnn(x, initial_state=[state1, state2..])

The initial readout (at t=0) will be zeros. You can set it using a tensor if you wish:

y = rnn(x, initial_state=[state1, state2..], initial_readout=some_tensor)

from recurrentshop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.