Skip to content

Instantly share code, notes, and snippets.

def EM_Gaussian(mu_init, sd_init, pi_init, n_iter=1000):
# EM for Gaussian mixture models
mu = mu_init
sd = sd_init
pi = pi_init
K = len(pi_init) # number of Gaussians
for n in range(n_iter):
# Expectation step
# calculate responsibilities for each Guassian
@louislung
louislung / 0_readme.md
Last active January 29, 2024 10:37
Keras implementation of RankNet

This gist is the implementation of RankNet using Keras Functional Api

For details please check this blog post.

keywords: learning to rank | tensorflow | keras | custom training loop | ranknet | lambdaRank

@maximlt
maximlt / run_python_script_in_conda_env.bat
Last active May 2, 2025 11:15
Run a Python script in a conda environment from a batch file
@echo OFF
rem How to run a Python script in a given conda environment from a batch file.
rem It doesn't require:
rem - conda to be in the PATH
rem - cmd.exe to be initialized with conda init
rem Define here the path to your conda installation
set CONDAPATH=C:\ProgramData\Miniconda3
rem Define here the name of the environment
@matteyeux
matteyeux / install_libimobiledevice.sh
Created January 7, 2019 12:39
Script to install libimobiledevice
#!/bin/bash
#######################################################################
#
# Project......: install_libimobiledevice.sh
# Creator......: Dev-Jam remasterized by matteyeux on 27/12/15
#######################################################################
echo -e "\033[31mDev-Jam 12/01/2015 - Script to build & install Libimobiledevice\033[0m"
echo -e "\033[32m\033[1m\033[4m\033[5m\033[7mCreated by Dev-Jam, improved by @matteyeux on 27/12/15\033[0m"
@d3rezz
d3rezz / finetune.py
Last active June 7, 2019 16:39
Finetuning a tensorflow slim model (Resnet v1 50) with a dataset in TFRecord format
# Finetune a tensorflow slim model (Resnet v1 50) on the flowers dataset in TFRecord format
# TFRecord files created using the script from https://github.com/kwotsin/create_tfrecords
# Trainining done in a Keras like way, where training and validation accuracy are computed every epoch
# Download resnet checkpoint from: http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz
import tensorflow as tf
import numpy as np
import os
import glob
from tqdm import tqdm
@bhavika
bhavika / finetune.py
Created November 25, 2017 21:45 — forked from panovr/finetune.py
Fine-tuning pre-trained models with PyTorch
import argparse
import os
import shutil
import time
import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.optim
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties config-number
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties serial-number
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties mlb-serial-number
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties IOPlatformSerialNumber
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties IOPlatformUUID
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties BootSessionUUID
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties SleepWakeUUID
Sep 28 22:49:11 iPhone-6S-Plus kernel[0] <Notice>: Sandbox: IOKitBrowser(1306) deny(1) iokit-get-properties IOCPUID
Sep 28 22:49:11 iPhone-6S-Plus kernel[
@karpathy
karpathy / min-char-rnn.py
Last active October 13, 2025 15:32
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@felHR85
felHR85 / UsbData.java
Last active June 25, 2025 08:08
An easy to use android solution to get a readable representation of Usb vid (vendor name) and pid (product name). Data is collected and stored in a local SQLite database from http://www.linux-usb.org/usb-ids.html
public class UsbData
{
private String vendorId;
private String vendorName;
private String productId;
private String productName;
public UsbData(String vendorId, String vendorName, String productId, String productName)
{
@jvranish
jvranish / stack_traces.c
Last active April 19, 2025 03:39
An example of catching exceptions and printing stack traces in C on Windows, Linux and OS X
/* compile with:
on linux: gcc -g stack_traces.c
on OS X: gcc -g -fno-pie stack_traces.c
on windows: gcc -g stack_traces.c -limagehlp
*/
#include <signal.h>
#include <stdio.h>
#include <assert.h>