My Elasticsearch cheatsheet with example usage via rest api (still a work-in-progress)
This file contains 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 sklearn.metrics.pairwise import cosine_similarity | |
def maximal_marginal_relevance(sentence_vector, phrases, embedding_matrix, lambda_constant=0.5, threshold_terms=10): | |
""" | |
Return ranked phrases using MMR. Cosine similarity is used as similarity measure. | |
:param sentence_vector: Query vector | |
:param phrases: list of candidate phrases | |
:param embedding_matrix: matrix having index as phrases and values as vector | |
:param lambda_constant: 0.5 to balance diversity and accuracy. if lambda_constant is high, then higher accuracy. If lambda_constant is low then high diversity. | |
:param threshold_terms: number of terms to include in result set |
This file contains 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 numpy as np | |
def largest_indices(array: np.ndarray, n: int) -> tuple: | |
"""Returns the n largest indices from a numpy array. | |
Arguments: | |
array {np.ndarray} -- data array | |
n {int} -- number of elements to select |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 dice_loss(pred, target): | |
"""This definition generalize to real valued pred and target vector. | |
This should be differentiable. | |
pred: tensor with first dimension as batch | |
target: tensor with first dimension as batch | |
""" | |
smooth = 1. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This is an Keras implementation of ResNet-101 with ImageNet pre-trained weights. I converted the weights from Caffe provided by the authors of the paper. The implementation supports both Theano and TensorFlow backends. Just in case you are curious about how the conversion is done, you can visit my blog post for more details.
ResNet Paper:
Deep Residual Learning for Image Recognition.
Kaiming He, Xiangyu Zhang, Shaoqing Ren, Jian Sun
arXiv:1512.03385
This file contains 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
#!/bin/bash | |
# | |
# EDIT: this script is outdated, please see https://forums.developer.nvidia.com/t/pytorch-for-jetson-nano-version-1-6-0-now-available | |
# | |
sudo apt-get install python-pip | |
# upgrade pip | |
pip install -U pip | |
pip --version | |
# pip 9.0.1 from /home/ubuntu/.local/lib/python2.7/site-packages (python 2.7) |
This file contains 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 numpy as np | |
import scipy as sp | |
import pandas as pd | |
import sklearn | |
from matplotlib import pyplot as plt | |
from sklearn import preprocessing | |
from sklearn.cross_validation import cross_val_predict | |
from sklearn import metrics | |
from sklearn.metrics import classification_report | |
from itertools import cycle |
This file contains 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
Initial positions | |
Player A: | |
[0-5] [1-3] [1-4] [2-2] [3-4] [4-4] [5-6] | |
Player B: | |
[0-0] [0-1] [0-6] [1-1] [1-6] [2-3] [2-6] | |
Player C: | |
[0-2] [2-4] [2-5] [3-3] [3-6] [4-5] [4-6] | |
Player D: | |
[0-3] [0-4] [1-2] [1-5] [3-5] [5-5] [6-6] |
NewerOlder