This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def make_heatmap(text, values, save=None, polarity=1): | |
| cell_height=.325 | |
| cell_width=.15 | |
| n_limit = 74 | |
| text = list(map(lambda x: x.replace('\n', '\\n'), text)) | |
| num_chars = len(text) | |
| total_chars = math.ceil(num_chars/float(n_limit))*n_limit | |
| mask = np.array([0]*num_chars + [1]*(total_chars-num_chars)) | |
| text = np.array(text+[' ']*(total_chars-num_chars)) | |
| values = np.array(values+[0]*(total_chars-num_chars)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For small files | |
| wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1rC6LWGNkHaZkuojCEWDqSKcDGwFMBTYZ' -O transformer_semeval.clf | |
| For large files | |
| wget --load-cookies cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1rC6LWGNkHaZkuojCEWDqSKcDGwFMBTYZ' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1rC6LWGNkHaZkuojCEWDqSKcDGwFMBTYZ" -O transformer_semeval.clf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Learning Structured Representation for Text Classification | |
| via Reinforcement Learning | |
| https://github.com/keavil/AAAI18-code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def reduce_mem_usage(df): | |
| """ iterate through all the columns of a dataframe and modify the data type | |
| to reduce memory usage. | |
| """ | |
| start_mem = df.memory_usage().sum() / 1024**2 | |
| print('Memory usage of dataframe is {:.2f} MB'.format(start_mem)) | |
| for col in df.columns: | |
| col_type = df[col].dtype | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import tensorflow as tf | |
| import tensorflow_hub as hub | |
| module_url = "https://tfhub.dev/google/universal-sentence-encoder-large/3" | |
| # Import the Universal Sentence Encoder's TF Hub module | |
| embed = hub.Module(module_url) | |
| # Compute a representation for each message, showing various lengths supported. | |
| messages = ["That band rocks!", "That song is really cool."] | |
| with tf.Session() as session: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from IPython import display | |
| for i in range(100): | |
| display.clear_output(wait=True) | |
| print(i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo add-apt-repository ppa:graphics-drivers -y | |
| sudo apt-get update | |
| sudo apt-get install nvidia-driver-418 nvidia-utils-418 nvidia-settings -y | |
| wget -N https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run | |
| wget -N http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/libcudnn7_7.5.0.56-1+cuda10.1_amd64.deb | |
| sudo ./cuda_10.1.105_418.39_linux.run --override --silent --toolkit --no-opengl-libs | |
| sudo dpkg -i libcudnn7_7.5.0.56-1+cuda10.1_amd64.deb | |
| sudo apt-get install libcupti-dev -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Setting default encoding python ENV - Ubuntu (Linux) - /bin/bash | |
| export PYTHONIOENCODING=UTF-8 | |
| ***************************************************************************************** | |
| # Making python server on any directory | |
| python3 -m http.server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cd ~ && python3 -m http.server 8082 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ttyd -p 5055 -i 0.0.0.0 -R tmux a -r -t 1 | |