ReactJS difference between stateful and stateless

Yes, that is sort of the difference. Except with the stateful component you can also change the state, using this.setState for example: var React = require(‘react’); var Header = React.createClass({ getInitialState: function() { return { imageSource: “mypicture.png” }; }, changeImage: function() { this.setState({imageSource: “differentpicture.png”}); }, render: function() { return( <img src={this.state.imageSource} onClick={this.changeImage.bind(this)} /> ); } … Read more

Stateless vs Stateful

Stateless means there is no memory of the past. Every transaction is performed as if it were being done for the very first time. Stateful means that there is memory of the past. Previous transactions are remembered and may affect the current transaction. Stateless: // The state is derived by what is passed into the … Read more

TensorFlow: Remember LSTM state for next batch (stateful LSTM)

I found out it was easiest to save the whole state for all layers in a placeholder. init_state = np.zeros((num_layers, 2, batch_size, state_size)) … state_placeholder = tf.placeholder(tf.float32, [num_layers, 2, batch_size, state_size]) Then unpack it and create a tuple of LSTMStateTuples before using the native tensorflow RNN Api. l = tf.unpack(state_placeholder, axis=0) rnn_tuple_state = tuple( [tf.nn.rnn_cell.LSTMStateTuple(l[idx][0], … Read more