Comments (4)
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.
Also checkout docs/readout.md
from recurrentshop.
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.
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)
- Dropout in Readout Model
- RecurrentModel without Cell
- AssertionError: Required 2 inputs, received 3.
- ImportError: cannot import name 'RecurrentSequentiaĺ'
- Error when combining teacherforce/readout with return_states
- Setting states for rnn forecasting
- update version HOT 1
- TypeError: can only concatenate tuple (not "int") to tuple HOT 3
- RNN with missing inputs
- Installation issue
- Decoder variable output_length? HOT 2
- How to transition between readout and teacher forcing?
- load model error with attention model
- Tensorflow2.0 support?
- AttributeError: 'Node' object has no attribute 'output_masks' HOT 1
- NameError: name 'K' is not defined HOT 1
- NameError: name 'activations' is not defined HOT 2
- NameError: name 'activations' is not defined HOT 2
- Error fix
- ImportError: cannot import name 'tensorflow_backend' HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recurrentshop.