Skip to content

Instantly share code, notes, and snippets.

View VieVie31's full-sized avatar
πŸ‘¨β€πŸ’»

Olivier RISSER-MAROIX VieVie31

πŸ‘¨β€πŸ’»
View GitHub Profile
@heri16
heri16 / 0-README.md
Last active April 19, 2025 09:45
Secure Short Unique IDs (for generating Invites Codes or Promo Codes or URL slug from Postgres Database)

What

This is open-source code that lets you generate short unique identifiers from numbers (within Postgres DB). These IDs are URL-safe, can encode several numbers, and do not contain common profanity words.

This is what they look like:

https://example.com/order/FHxkSB1ai
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
@kernel1994
kernel1994 / top_k.py
Last active October 26, 2021 01:06
Top k element index in numpy array
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
@kylemcdonald
kylemcdonald / ACAI (PyTorch).ipynb
Last active March 12, 2023 18:37
PyTorch ACAI (1807.07543).
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@weiliu620
weiliu620 / Dice_coeff_loss.py
Last active July 19, 2023 10:30
Dice coefficient loss function in PyTorch
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.
@ruanbekker
ruanbekker / cheatsheet-elasticsearch.md
Last active May 1, 2025 14:42
Elasticsearch Cheatsheet : Example API usage of using Elasticsearch with curl
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@flyyufelix
flyyufelix / readme.md
Last active November 16, 2021 00:09
Resnet-101 pre-trained model in Keras

ResNet-101 in Keras

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
@dusty-nv
dusty-nv / pytorch_jetson_install.sh
Last active March 21, 2025 16:39
Install procedure for pyTorch on NVIDIA Jetson TX1/TX2 with JetPack <= 3.2.1. For JetPack 4.2 and Xavier/Nano/TX2, see https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/
#!/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)
@ericshape
ericshape / flight_prediction.py
Created December 19, 2016 19:18
Flight Prediction Python Code
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