Skip to content

Instantly share code, notes, and snippets.

View trcook's full-sized avatar

Tom Cook trcook

View GitHub Profile
@trcook
trcook / .env
Last active May 6, 2024 20:58
ooba docker config stuff
TORCH_CUDA_ARCH_LIST=8.6
HOST_API_PORT=3389
HOST_PORT=8888
CONTAINER_PORT=7860
CONTAINER_API_PORT=5000
BUILD_EXTENSIONS=""
TRANSFORMERS_CACHE=/home/app/text-generation-webui/cache/
HF_HOME=/home/app/text-generation-webui/cache/
COMPOSE_PROJECT_NAME=trc #name for container will be trc_{service}
@trcook
trcook / layer.py
Last active April 18, 2019 16:02
create a layer in keras that dynaically adjusts shape according to size of input
# problem: sometimes we want a network that will start with a layer equal to the number of input neurons with fewer and fewer neurons in each subsequent neuron
class DenseLayer(k.layers.Layer):
def __init__(self):
super().__init__()
def build(self,input_shape):
self.layer_list=[]
size=input_shape[-1]
print(size)
@trcook
trcook / logging.py
Last active October 12, 2018 19:30
LOGGING setup logging in python
import logging
logging.basicConfig(format='|%(levelname)s| (%(name)s) %(lineno)d:> %(message)s',datefmt='%m/%d/%Y %H:%M:%S')
logger=logging.getLogger(name=__file__)
ld=logger.debug
li=logger.info
lw=logger.warning
logger.setLevel(logging.DEBUG)
@trcook
trcook / tf_record_reader_example.py
Last active September 16, 2018 00:45
tf record writer for image data. files for writing tfrecords and reading tfrecords into tensorflow datasets
import tensorflow as tf
class GWData(object):
"""
# usage: make a dataset by passing in a tfrecord. Format will need to line up with output produced in tf_record_writer.py
# For a more easily workable example: https://gist.github.com/trcook/9fc8698cf7dc848a953f8e7a7e5f1aad
:Example:
@trcook
trcook / insert_date.tex
Created May 9, 2018 19:16
create last revised watermark on latex memo
\usepackage[]{gitinfo2}
\begin{document}
\begin{tikzpicture}[remember picture,overlay]
\node at ([xshift=3cm,yshift=2cm]current page.south west) {\tiny \color[gray]{.8} Last Revised: \gitAuthorDate}; %% yshift and xshift for example only
\end{tikzpicture}
\end{document}
@trcook
trcook / denoising.py
Created May 2, 2018 13:52
denoising autoencoder for data imputation
import keras as K
from keras.models import Sequential
from sklearn.preprocessing import MinMaxScaler
import pandas as pd
import numpy as np
import fredapi
fred_key="ADD FRED KEY FILE HERE"
fred=fredapi.fred.Fred(api_key_file=fred_key)
@trcook
trcook / tf_estimator_example.py
Created April 3, 2018 19:29
basic example using tf estimators as of 1.4
def input_fn(total_repeats=int(1e8),batch_size=100):
x=tf.constant([
[[0,1]],
[[0,0]],
[[1,1]],
[[1,0]]
],dtype=tf.float32)
y=tf.constant([
@trcook
trcook / keras_tensorflow.py
Last active March 21, 2018 19:00
basic mix of tensorflow and keras in the same file. Also makes use of tf.data
from keras import backend as K
import keras as k
from keras.layers import *
import tensorflow as tf
tf.reset_default_graph()
g=tf.get_default_graph()
sess=tf.Session()
K.set_session(sess)
@trcook
trcook / file.py
Created December 15, 2017 15:03
change cell-width in jupyter
# enter into jupyter cell and execute
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
@trcook
trcook / show_library.sh
Created August 9, 2017 18:13
force os x to show library
chflags nohidden ~/Library/