Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# ./bundle-packages requirements.txt ./target-directory
# where
# requirements.txt : list of packages to include
# ./packages : path to target file
virtualenv --no-site-packages packageenv
. packageenv/bin/activate
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the CC-by-NC license found in the
# LICENSE file in the root directory of this source tree.
# -*- makefile -*-
#
# Ubuntu 14.04 (eg Docker)
@bkj
bkj / pytorch_lifted_loss.py
Last active April 28, 2022 07:12
pytorch lifted loss
#!/usr/bin/env python
"""
pytorch_lifted_loss.py
"""
import torch
import torch.nn as nn
from torch.autograd import Variable
@bkj
bkj / keras_lifted_loss.py
Last active July 5, 2019 02:07
keras lifted loss
#!/usr/bin/env python
"""
keras_lifted_loss.py
"""
from keras import backend as K
def lifted_loss(margin=1):
"""
#!/usr/bin/env python
"""
pytorch_dlib_metric_loss.py
"""
import torch
import torch.nn as nn
from torch.autograd import Variable
#!/usr/bin/env python
"""
get_list.py
Example:
./code/get_list.py ./data/casia/ > ./data/train.txt
"""
from __future__ import print_function
#!/usr/bin/env python
"""
mnist_cnn.py
"""
from __future__ import print_function
import keras
from keras.datasets import mnist
from keras.models import Sequential
@bkj
bkj / id2url.py
Last active August 9, 2017 16:51
id2url.py
#!/usr/bin/env python
"""
id2url.py
Convert instagram post id to the url
"""
import os
from string import letters
# Copyright (c) 2015-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD+Patents license found in the
# LICENSE file in the root directory of this source tree.
# -*- makefile -*-
# tested on CentOS 7, Ubuntu 16 and Ubuntu 14, see below to adjust flags to distribution.
#!/bin/bash
echo $1
cd $1
touch _start
gzip -cd $1.gz > urls
cat urls | sed 's@https://@out=@g' | paste urls - | sed 's/\t/\n\t/g' > aria-urls
aria2c -j8 --deferred-input --conditional-get=true --auto-file-renaming=false -q -i aria-urls
touch _finish
cd ..