Skip to content

Instantly share code, notes, and snippets.

@louislung
louislung / 0_Readme.md
Last active June 30, 2022 00:55
Implement Factorised RankNet (speedup version of RankNet) using tensorflow 2.0

Factorised RankNet TensorFlow Implementation

For details please check this blog post

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

@blepfo
blepfo / TensorFlow-Best-Practices-Q1-2018.md
Last active December 13, 2018 10:22
TensorFlow Best Practices as of Q1 2018

TensorFlow Best Practices as of Q1 2018

By Adam Anderson

adam.b.anderson.96@gmail.com

Preface

This write-up assumes you have an general understanding of the TensorFlow programming model, but maybe you haven't kept up to date with the latest library features/standard practices.

@higepon
higepon / seq2seq.py
Last active August 1, 2023 09:05
Minimum Seq2Seq implementation using Tensorflow 1.4/1.5 API
import numpy as np
import tensorflow as tf
from tensorflow.python.layers import core as layers_core
hparams = tf.contrib.training.HParams(
batch_size=3,
encoder_length=4,
decoder_length=5,
num_units=6,
src_vocab_size=7,
@dolaameng
dolaameng / mnist_estimator.py
Created October 19, 2017 03:34 — forked from peterroelants/mnist_estimator.py
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.3"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
from tensorflow.contrib.learn import ModeKeys
from tensorflow.contrib.learn import learn_runner
# Show debugging output
@damienpontifex
damienpontifex / tf-experiment-template.py
Last active March 9, 2021 09:43
A template for a custom tensorflow estimator and experiment with python3 typings for desired parameter types
import argparse
import psutil
import tensorflow as tf
from typing import Dict, Any, Callable, Tuple
## Data Input Function
def data_input_fn(data_param,
batch_size:int=None,
shuffle=False) -> Callable[[], Tuple]:
"""Return the input function to get the test data.
@peterroelants
peterroelants / mnist_estimator.py
Last active February 14, 2024 11:26
Example using TensorFlow Estimator, Experiment & Dataset on MNIST data.
"""Script to illustrate usage of tf.estimator.Estimator in TF v1.3"""
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data as mnist_data
from tensorflow.contrib import slim
from tensorflow.contrib.learn import ModeKeys
from tensorflow.contrib.learn import learn_runner
# Show debugging output
@teamdandelion
teamdandelion / labels_1024.tsv
Last active February 6, 2024 08:33
TensorBoard: TF Dev Summit Tutorial
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
7
2
1
0
4
1
4
9
5
9
@benwu232
benwu232 / tf_restore.py
Created February 8, 2017 07:11
Show how to restore model, parameters, inputs and outputs
import tensorflow as tf
tf.GraphKeys.USEFUL = 'useful'
saver = tf.train.import_meta_graph("./model_ex1.meta")
sess = tf.Session()
saver.restore(sess, "./model_ex1")
var_list = tf.get_collection(tf.GraphKeys.USEFUL)
v1 = var_list[0]
@floriandotpy
floriandotpy / optimize.py
Created October 5, 2016 08:46
Hyperopt script for Tensorflow model
#!/usr/bin/python3
from cnn import cnn
import hyperopt
def objective(args):
params = cnn.ExperimentParameters()
@siemanko
siemanko / tf_lstm.py
Last active July 26, 2023 06:57
Simple implementation of LSTM in Tensorflow in 50 lines (+ 130 lines of data generation and comments)
"""Short and sweet LSTM implementation in Tensorflow.
Motivation:
When Tensorflow was released, adding RNNs was a bit of a hack - it required
building separate graphs for every number of timesteps and was a bit obscure
to use. Since then TF devs added things like `dynamic_rnn`, `scan` and `map_fn`.
Currently the APIs are decent, but all the tutorials that I am aware of are not
making the best use of the new APIs.
Advantages of this implementation: