Skip to content

Instantly share code, notes, and snippets.

💭
Working on TensorFlow Ranking

Alex Egg eggie5

💭
Working on TensorFlow Ranking
Block or report user

Report or block eggie5

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
View verify_tfrecords.py
"""Checks if a set of TFRecords appear to be valid.
Specifically, this checks whether the provided record sizes are consistent and
that the file does not end in the middle of a record. It does not verify the
CRCs.
"""
import struct
from multiprocessing import Pool
import tensorflow as tf
View saved_model_cli_bug.md

The saved model CLI can't handle string input w/ the input_examples flag RE: https://github.com/tensorflow/tensorflow/issues/27662 :

saved_model_cli run \
--dir . \
--tag_set serve \
--signature_def predict \
--input_examples 'examples=[{"menu_item":["this is a sentence"]}]'
View tf-saved-model.java
import org.tensorflow.Graph;
import org.tensorflow.Session;
import org.tensorflow.Tensor;
import org.tensorflow.Tensors;
import org.tensorflow.TensorFlow;
import org.tensorflow.SavedModelBundle;
import org.tensorflow.SavedModelBundle.Loader;
import org.tensorflow.framework.SignatureDef;
import org.tensorflow.framework.MetaGraphDef;
import org.tensorflow.framework.TensorInfo;
View py_data_ams_2018_proposal.md

Learning to Rank

A common method to rank a set of items is to pass all items through a scoring function and then sorting the scores to get an overall rank. Traditionally this space has been domianted by ordinal regression techniques on point-wise data. However, there are serious advantages to exploit by learning a scoring function on pair-wise data instead. This technique commonly called RankNet was originally explored by the seminal Learning to Rank by Gradient Descent[^1] paper by Microsoft.

In this talk we will discuss:

  • Theory behind point-wise and pair-wise data

  • Ordinal Regression: ranking point-wise data

  • how to crowd-source pair-wise data

View fm.py
import numpy as np
from sklearn.base import BaseEstimator
from keras.layers import Input, Embedding, Dense,Flatten ,Activation, Add, Dot
from keras.models import Model
from keras.regularizers import l2 as l2_reg
from keras import initializers
import itertools
def build_model(max_features,K=8,solver='adam',l2=0.0,l2_fm = 0.0):
View IRI-case-study.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View findphone.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eggie5
eggie5 / tensorflow_finetune.py
Created Dec 11, 2017 — 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 SavedModel_test.py
### We will try to seralize and desearlaize a graph that is using the new `get_single_element` function of the Dataset API
### You will see that it does not desearlize gracefully.
#### Part 1: Build arbitrary graph using Dataset API and new get_single_element function
import numpy as np
import tensorflow as tf
from tensorflow.contrib.data import Dataset, Iterator
View tf-ml.log
INFO 2017-02-27 09:29:43 -0800 master-replica-0 Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0)
INFO 2017-02-27 10:51:58 -0800 master-replica-0 max_u_id: 6040
INFO 2017-02-27 10:51:58 -0800 master-replica-0 max_i_id: 3952
INFO 2017-02-27 10:51:58 -0800 master-replica-0 epoch: 1
INFO 2017-02-27 10:51:58 -0800 master-replica-0 bpr_loss: 0.718087361238
INFO 2017-02-27 10:51:58 -0800 master-replica-0 test_loss: 0.941205 test_auc: 0.633492314296
INFO 2017-02-27 10:51:58 -0800 master-replica-0 epoch: 2
INFO 2017-02-27 10:51:58 -0800 master-replica-0 bpr_loss: 0.706146094591
INFO 2017-02-27 10:51:58 -0800 master-replica-0 test_loss: 0.933789 test_auc: 0.701774210244
INFO 2017-02-27 10:51:58 -0800 master-replica-0 epoch: 3
You can’t perform that action at this time.