def show_fixed_points(self, ff):
        NOISE_SCALE = 0.5  # Standard deviation of noise added to initial states
        N_INITS = 2048  # The number of initial states to provide

        n_bits = ff.hps.data_hps['n_bits']
        is_lstm = ff.hps.rnn_type == 'lstm'
        '''Fixed point finder hyperparameters. See FixedPointFinder.py for detailed
        descriptions of available hyperparameters.'''
        fpf_hps = {}

        # Setup the fixed point finder
        fpf = FixedPointFinder(ff.rnn_cell, ff.session, **fpf_hps)

        # Study the system in the absence of input pulses (e.g., all inputs are 0)
        inputs = np.zeros([1, n_bits])
        example_trials = ff.generate_SineWave_trials()
        '''Draw random, noise corrupted samples of those state trajectories
        to use as initial states for the fixed point optimizations.'''
        example_predictions = ff.predict(example_trials,
                                         do_predict_full_LSTM_state=is_lstm)

        initial_states = fpf.sample_states(example_predictions['state'],
                                           n_inits=N_INITS,
                                           noise_scale=NOISE_SCALE)

        # Run the fixed point finder
        unique_fps, all_fps = fpf.find_fixed_points(initial_states, inputs)

        # Visualize identified fixed points with overlaid RNN state trajectories
        # All visualized in the 3D PCA space fit the the example RNN states.
        plot_fps(unique_fps,
                 example_predictions['state'],
                 plot_batch_idx=range(30),
                 plot_start_time=10)

        print(
            'Entering debug mode to allow interaction with objects and figures.'
        )
        pdb.set_trace()
def find_fixed_points(model, valid_predictions):
    ''' Find, analyze, and visualize the fixed points of the trained RNN.

    Args:
        model: FlipFlop object.

            Trained RNN model, as returned by train_FlipFlop().

        valid_predictions: dict.

            Model predictions on validation trials, as returned by
            train_FlipFlop().

    Returns:
        None.
    '''

    '''Initial states are sampled from states observed during realistic
    behavior of the network. Because a well-trained network transitions
    instantaneously from one stable state to another, observed networks states
    spend little if any time near the unstable fixed points. In order to
    identify ALL fixed points, noise must be added to the initial states
    before handing them to the fixed point finder. In this example, the noise
    needed is rather large, which can lead to identifying fixed points well
    outside of the domain of states observed in realistic behavior of the
    network--such fixed points can be safely ignored when interpreting the
    dynamical landscape (but can throw visualizations).'''

    NOISE_SCALE = 0.5 # Standard deviation of noise added to initial states
    N_INITS = 1024 # The number of initial states to provide

    n_bits = model.hps.data_hps['n_bits']
    is_lstm = model.hps.rnn_type == 'lstm'

    '''Fixed point finder hyperparameters. See FixedPointFinder.py for detailed
    descriptions of available hyperparameters.'''
    fpf_hps = {}

    # Setup the fixed point finder
    fpf = FixedPointFinder(model.rnn_cell, model.session, **fpf_hps)

    # Study the system in the absence of input pulses (e.g., all inputs are 0)
    inputs = np.zeros([1,n_bits])

    '''Draw random, noise corrupted samples of those state trajectories
    to use as initial states for the fixed point optimizations.'''
    initial_states = fpf.sample_states(valid_predictions['state'],
        n_inits=N_INITS,
        noise_scale=NOISE_SCALE)

    # Run the fixed point finder
    unique_fps, all_fps = fpf.find_fixed_points(initial_states, inputs)

    # Visualize identified fixed points with overlaid RNN state trajectories
    # All visualized in the 3D PCA space fit the the example RNN states.
    plot_fps(unique_fps, valid_predictions['state'],
        plot_batch_idx=list(range(30)),
        plot_start_time=10)

    print('Entering debug mode to allow interaction with objects and figures.')
    print('You should see a figure with:')
    print('\tMany blue lines approximately outlining a cube')
    print('\tStable fixed points (black dots) at corners of the cube')
    print('\tUnstable fixed points (red lines or crosses) '
        'on edges, surfaces and center of the cube')
    print('Enter q to quit.\n')
    pdb.set_trace()
'''Fixed point finder hyperparameters. See FixedPointFinder.py for detailed
descriptions of available hyperparameters.'''
fpf_hps = {}

# Setup the fixed point finder
fpf = FixedPointFinder(ff.rnn_cell,
                       ff.session,
                       **fpf_hps)

# Study the system in the absence of input pulses (e.g., all inputs are 0)
inputs = np.zeros([1,n_bits])

'''Draw random, noise corrupted samples of those state trajectories
to use as initial states for the fixed point optimizations.'''
example_predictions, example_summary = ff.predict(example_trials)
initial_states = fpf.sample_states(example_predictions['state'],
                                   n_inits=N_INITS,
                                   noise_scale=NOISE_SCALE)

# Run the fixed point finder
unique_fps, all_fps = fpf.find_fixed_points(initial_states, inputs)

# Visualize identified fixed points with overlaid RNN state trajectories
# All visualized in the 3D PCA space fit the the example RNN states.
plot_fps(unique_fps, example_predictions['state'],
    plot_batch_idx=range(30),
    plot_start_time=10)

print('Entering debug mode to allow interaction with objects and figures.')
pdb.set_trace()