Skip to content

Instantly share code, notes, and snippets.

@MikeOfZen
MikeOfZen / affinity
Created November 21, 2019 07:28
[Select CPU core]
start /affinity 1 program.exe
this will run program.exe on the first CPU as "1" is the hex value of the affinity mask
CPU3 CPU2 CPU1 CPU0 Bin Hex
---- ---- ---- ---- --- ---
OFF OFF OFF ON = 0001 = 1
OFF OFF ON OFF = 0010 = 2
OFF OFF ON ON = 0011 = 3
OFF ON OFF OFF = 0100 = 4
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@MikeOfZen
MikeOfZen / get_layers_above
Created November 5, 2019 19:06
[Cut TF model] use this to slice a keras model in half. useful for transfer learning in large models #tf #python
def get_next_level(layer,model):
def wrap_list(val):
if type(val) is list:
return val
return [val]
r=[]
for output_t in wrap_list(layer.output):
r+=[x for x in model.layers if output_t.name in [y.name for y in wrap_list(x.input)]]
return r
@MikeOfZen
MikeOfZen / tfds_split
Last active October 31, 2019 22:45
[tfds get dataset] get dataset and do split 3 way #tf #python #split #dataset #tfds
DATA_DIR="/tmp"
test_split, valid_split, train_split = tfds.Split.TRAIN.subsplit([10, 10, 80])
test_set = tfds.load("cats_vs_dogs:4.*.*",data_dir=DATA_DIR, split="train[:10%]", as_supervised=True)
valid_set = tfds.load("cats_vs_dogs:4.*.*",data_dir=DATA_DIR, split="train[10%:20%]", as_supervised=True)
train_set = tfds.load("cats_vs_dogs:4.*.*",data_dir=DATA_DIR, split="train[20%:]", as_supervised=True)
#tfds.load is called multiple times for each slice, the 'train' split name is taken from the dataset documentation