Your Data#
Run this notebook on Google Colab:
Find the documentation of EncoderMap:
https://ag-peter.github.io/encodermap
Goals
In this tutorial, you can train EncoderMap on your own data.
eor Google colab only:
If you’re on Google colab, please uncomment these lines and install EncoderMap.
[1]:
# !wget https://gist.githubusercontent.com/kevinsawade/deda578a3c6f26640ae905a3557e4ed1/raw/b7403a37710cb881839186da96d4d117e50abf36/install_encodermap_google_colab.sh
# !sudo bash install_encodermap_google_colab.sh
Primer
Now it’s time to take advantage of your new knowledge about dimensionality reduction with EncoderMap. Load your own data and get started! The data set you use should be a table where each line contains one sample and the number of columns is the dimensionality of the data-set.
Load Libraries#
[2]:
import encodermap as em
import numpy as np
/home/kevin/git/encoder_map_private/encodermap/__init__.py:194: GPUsAreDisabledWarning: EncoderMap disables the GPU per default because most tensorflow code runs with a higher compatibility when the GPU is disabled. If you want to enable GPUs manually, set the environment variable 'ENCODERMAP_ENABLE_GPU' to 'True' before importing EncoderMap. To do this in python you can run:
import os; os.environ['ENCODERMAP_ENABLE_GPU'] = 'True'
before importing encodermap.
_warnings.warn(
Load Your Data#
[ ]:
csv_path = "path/to/your/data.csv"
high_d_data = np.loadtxt(csv_path, delimiter=",")
Set Parameters#
[4]:
parameters = em.Parameters()
parameters.n_steps = 1000
parameters.dist_sig_parameters = [40, 10, 5, 1, 2, 5]
parameters.periodicity = 2*np.pi
# if your data set is large you should not try to calculate
# the pairwise distance histogram with the complete data.
em.plot.distance_histogram_interactive(
data=high_d_data, # e.g. use high_d_data[::10] to use evrey 10th point
periodicity=parameters.periodicity,
initial_guess=parameters.dist_sig_parameters,
)
[4]:
Run the Dimensionality Reduction#
[ ]:
e_map = em.EncoderMap(parameters, high_d_data)
history = e_map.train()
low_d_projection = e_map.encode(dihedrals)
Plot the Results#
[6]:
em.plot.plot_free_energy(
*low_d_projection.T
)