Skip to content

Instantly share code, notes, and snippets.

View lefnire's full-sized avatar

Tyler Renelle lefnire

View GitHub Profile

Release Notes

New Thing 6

7/16/2018

About this

New Thing 5

7/14/2018

About this

New Thing 4

7/14/2018

About this

Release Notes

New Thing 2

7/16/2018

About this

New Thing 2

7/14/2018

About this

@lefnire
lefnire / bert_dist_cluster.py
Last active September 16, 2022 13:27
BERT embeddings similarity & clustering
import math
import torch
from sklearn.cluster import AgglomerativeClustering
from sentence_transformers import SentenceTransformer
def normalize(x):
"""
Need this method for cosine(), because otherwise we're dealing with dot-product on non-normalized data (which isn't cosine).
BERT embeddings typically range [-7 7], so this is needed.
Generating example data...
[0.223 0. 0. 0. 0. 0.196 0. 0. 0. 0. 0.225 0.
0. 0. 0. 0.17 0. 0. 0. 0. 0.186 0. 0. 0.
0. ]
[0.223 0. 0. 0. 0. 0.196 0. 0. 0. 0. 0.225 0.
0. 0. 0. 0.17 0. 0. 0. 0. 0.186 0. 0. 0.
0. ]
[0.223 0. 0. 0. 0. 0.196 0. 0. 0. 0. 0.225 0.
0. 0. 0. 0.17 0. 0. 0. 0. 0.186 0. 0. 0.
0. ]
df = pd.read_csv(
data_path('Model_Update_Data_April_2018.txt'),
sep='\t',
true_values=['Y', 'True', 'TRUE'],
false_values=['N', 'False', 'FALSE'],
na_values=['?', 'U', 'Unknown']
)
na_cols = df.columns[df.isna().any()]
print(na_cols)
"""
@lefnire
lefnire / App.jsx
Last active January 31, 2018 22:39
import {Home} from './Home.js';
import React from 'react';
class App extends React.Component {
render() {
return (
<div className="container container-fluid">
<!-- maybe some menu / header stuff here. Anything that's shared b/w all your pages -->
<Home />
</div>
baseline_optimizer.optimizer.learning_rate: 0.1127
net.activation_tanh: 0.0854
baseline_optimizer.num_steps: 0.0569
entropy_regularization: 0.0549
source_kaggle2: 0.0499
net.depth: 0.0461
net.l1: 0.0456
net.width: 0.0428
discount: 0.0397
net.dropout: 0.0375
2017-10-06 19:57:20.025172: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-06 19:57:20.025184: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-06 19:57:20.025186: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-10-06 19:57:20.025188: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-10-06 19:57:20.025189: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA ins
(tensorflow1) lefnire@lefnire-ubuntu:~/Sites/btc/github/Multidimensional-LSTM-BitCoin-Time-Series$ python run.py
Using TensorFlow backend.
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CU
backports.weakref==1.0rc1
bleach==1.5.0
cycler==0.10.0
funcsigs==1.0.2
functools32==3.2.3.post2
h5py==2.7.0
html5lib==0.9999999
Keras==2.0.6
Markdown==2.6.8
matplotlib==2.0.2