Skip to content

Instantly share code, notes, and snippets.

View philipperemy's full-sized avatar
🇨🇵
Solving AI together.

Philippe Rémy philipperemy

🇨🇵
Solving AI together.
View GitHub Profile
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.applications import Xception
import numpy as np
num_samples = 1000
height = 224
width = 224
num_classes = 1000
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.use('MACOSX')
img_h, img_w = 250, 500
img = np.zeros((img_h, img_w))
import numpy as np
# FIND LARGEST K ELEMENTS IN A 2D ARRAY IN NUMPY
def find_k_largest_elements_in_2d_array(arr: np.array, k=1):
assert len(arr.shape) == 2
h, w = arr.shape
top_indices = np.flip(arr.flatten().argsort()[-k:])
return np.divmod(top_indices, w)
from __future__ import print_function
import os
import numpy as np
from keras.layers import RepeatVector
from keras.layers.core import Dropout
from keras.layers.recurrent import LSTM
from keras.models import Sequential
from keras.models import load_model
from __future__ import print_function
import numpy as np
from keras.callbacks import Callback
from keras.layers import Dense
from keras.layers import LSTM
from keras.models import Sequential
from numpy.random import choice
from utils import prepare_sequences
// y-cruncher Configuration File
// Version: 0.7.8 Build 9507
//
// Load this from y-cruncher or run directly:
// y-cruncher config filename.cfg
//
// If you're copying Windows file paths into here, be sure to replace
// all backslashes "\" with forward slashes "/". Backslash is an
// escape character.
//
import numpy as np
# online computation of the mean and the variance.
class RollingMean:
def __init__(self):
self.st = 0.0
self.n = 0
@philipperemy
philipperemy / pickle_view.py
Created March 14, 2017 05:52
Pickle viewer in command line! Put it here /usr/bin/pickle_view.py
#!/usr/bin/env python
import pickle
import sys
if __name__ == '__main__':
argv = sys.argv
if len(argv) <= 1:
print 'Specify pickle file as parameter.'
@philipperemy
philipperemy / count_downloads_pypi.py
Created November 6, 2023 03:26
Count the total downloads of your packages on PyPi
import requests
from bs4 import BeautifulSoup
def get_downloads_count(package_name: str):
badge_url = f"https://static.pepy.tech/badge/{package_name}"
response = requests.get(badge_url)
download_count = int(
BeautifulSoup(response.text, 'html.parser')
.find_all('text')[-1].text.replace('k', '000').replace('m', '000000')