Skip to content

Instantly share code, notes, and snippets.

Mehdi Cherti mehdidc

Block or report user

Report or block mehdidc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mehdidc
mehdidc / nes.py
Created Dec 24, 2018 — forked from karpathy/nes.py
Natural Evolution Strategies (NES) toy example that optimizes a quadratic function
View nes.py
"""
A bare bones examples of optimizing a black-box function (f) using
Natural Evolution Strategies (NES), where the parameter distribution is a
gaussian of fixed standard deviation.
"""
import numpy as np
np.random.seed(0)
# the function we want to optimize
View Using Github Deploy Key.md

What / Why

Deploy key is a SSH key set in your repo to grant client read-only (as well as r/w, if you want) access to your repo.

As the name says, its primary function is to be used in the deploy process, where only read access is needed. Therefore keep the repo safe from the attack, in case the server side is fallen.

How to

  1. Generate a ssh key
@mehdidc
mehdidc / tensorflow_finetune.py
Created Jun 8, 2018 — forked from omoindrot/tensorflow_finetune.py
Example TensorFlow script for fine-tuning a VGG model (uses tf.contrib.data)
View tensorflow_finetune.py
"""
Example TensorFlow script for finetuning a VGG model on your own data.
Uses tf.contrib.data module which is in release v1.2
Based on PyTorch example from Justin Johnson
(https://gist.github.com/jcjohnson/6e41e8512c17eae5da50aebef3378a4c)
Required packages: tensorflow (v1.2)
Download the weights trained on ImageNet for VGG:
```
wget http://download.tensorflow.org/models/vgg_16_2016_08_28.tar.gz
View projector_config.json
{
"embeddings": [
{
"tensorName": "WIPO",
"tensorShape": [
5799,
300
],
"tensorPath": "https://files.fm/down.php?i=yrkmskvv",
"metadataPath": "https://gist.githubusercontent.com/mehdidc/af6727cec814cb37a9bc36f6620bc288/raw/383d6805b294397307b659242328cd446cfded1f/labels.tsv"
View labels.tsv
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
portable bath bench/seat
bathtub
bath for invalid
a multi-purpose shower device
children's bath
a foot care device
a showering appliance
knockdown bath bench
safety devices
a shower-bath booth structure
View .vimrc
"FIRST do : curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
set autoindent
set nocindent
set nosmartindent
set autoindent
set indentexpr=
set tabstop=8
set expandtab
set shiftwidth=4
set softtabstop=4
View script.sh
wget https://downloads.rclone.org/v1.41/rclone-v1.41-linux-amd64.zip
unzip rclone-v1.41-linux-amd64.zip
wget https://gist.githubusercontent.com/mehdidc/9f9f7d1f96e2c53571dfac501f61dbbb/raw/252e45e95159dc311468e8aefa875700bce1d195/gistfile1.txt --output-document=$HOME/.rclone.conf
mkdir -p data
git clone https://github.com/tensorflow/models/
curl -OL https://github.com/google/protobuf/releases/download/v3.2.0/protoc-3.2.0-linux-x86_64.zip
rm -fr protoc && unzip protoc-3.2.0-linux-x86_64.zip -d protoc
cd models/research/ && ../../protoc/bin/protoc object_detection/protos/*.proto --python_out=.
pip install contextlib2
cp models/research/object_detection/dataset_tools/create_oid_tf_record.py .
View create_oid_tf_record.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
View cython_tricks.md

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

@mehdidc
mehdidc / Ubuntu1604py36Dockerfile
Created Apr 11, 2018 — forked from monkut/Ubuntu1604py36Dockerfile
Base Docker image for ubuntu-16.04 & Python3.6
View Ubuntu1604py36Dockerfile
# docker build -t ubuntu1604py36
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git
You can’t perform that action at this time.