Skip to content

Instantly share code, notes, and snippets.

View zmjjmz's full-sized avatar

Zachary Jablons zmjjmz

View GitHub Profile
@zmjjmz
zmjjmz / train_iris.py
Last active June 24, 2020 17:51
tabnet no variation
import os
import shutil
import tensorflow as tf
import tensorflow_datasets as tfds
import tabnet
import pandas as pd
import numpy as np
train_size = 125
BATCH_SIZE = 50
@zmjjmz
zmjjmz / TF segfault
Created April 1, 2020 19:58
TF segfault
W0401 13:47:33.782922 140134609663744 basic_session_run_hooks.py:732] It seems that global step (tf.train.get_global_step)
has not been increased. Current value (could be stable): 0 vs previous value: 0. You could increase the global step by pass
ing tf.train.get_global_step() to Optimizer.apply_gradients or Optimizer.minimize.
*** Error in `python': malloc(): memory corruption (fast): 0x00007f6f78326510 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x70bfb)[0x7f73a0777bfb]
/lib/x86_64-linux-gnu/libc.so.6(+0x76fc6)[0x7f73a077dfc6]
/lib/x86_64-linux-gnu/libc.so.6(+0x79491)[0x7f73a0780491]
/lib/x86_64-linux-gnu/libc.so.6(
@zmjjmz
zmjjmz / diagnose_tb.txt
Created March 23, 2020 23:23
Tensorboard Diagnostic
### Diagnostics
<details>
<summary>Diagnostics output</summary>
``````
--- check: autoidentify
INFO: diagnose_tensorboard.py version d515ab103e2b1cfcea2b096187741a0eeb8822ef
--- check: general
@zmjjmz
zmjjmz / keras_save_issue.py
Created March 13, 2020 21:49
TF save issue
import tensorflow as tf
from tensorflow import feature_column as fc
import pandas as pd
import numpy as np
FC_DISPATCH = {
'numeric': lambda key, training_vals, **kwargs: fc.numeric_column(key, **kwargs),
'categorical': lambda key, training_vals, **kwargs: fc.indicator_column(
fc.categorical_column_with_vocabulary_list(
@zmjjmz
zmjjmz / jax_shuffle_output.txt
Last active February 24, 2020 18:50
Jax shuffle vs. numpy shuffle
jax_jit_correlation jax_jit_time jax_nojit_correlation jax_nojit_time np_copy_correlation np_copy_time np_inplace_correlation np_inplace_time size
0 -0.087945 0.520224 -0.207465 0.515517 -0.086613 0.000577 -0.048701 0.000638 100
1 0.009647 0.409452 -0.009721 0.407500 -0.016213 0.000776 -0.032633 0.000694 1000
2 0.005357 0.652246 0.010250 0.633742 0.002910 0.003117 -0.001414 0.001872 10000
3 -0.002672 1.441106 0.000594 1.425177 0.004118 0.023031 -0.004778 0.017846 100000
4 0.001152 11.028948 0.000698 10.984871 -0.002028 0.228054 0.001034 0.163242 1000000
5 0.000007 250.970225 -0
@zmjjmz
zmjjmz / shuffle_behaviour.py
Created January 24, 2020 17:22
Jax random shuffle vs. numpy random shuffle
import numpy as onp
import jax.numpy as jnp
import jax.random as jrand
from jax import jit
@jit
def jax_shuffler(all_inputs, key):
shuffled_input = jrand.shuffle(key, all_inputs, axis=0)
return shuffled_input
@zmjjmz
zmjjmz / Error
Last active December 18, 2019 20:30
Dynamic Slices JAX
Traceback (most recent call last):
File "jax_models.py", line 232, in <module>
shuffle=True,
File "jax_models.py", line 181, in fit
voter_indices, target_indices, ratings, batch_size, batched_dataset_size)
File "/home/u1/zach/proj/dataplayground3/lib/python3.5/site-packages/jax/api.py", line 150, in f_jitted
out = xla.xla_call(flat_fun, *args_flat, device=device, backend=backend)
File "/home/u1/zach/proj/dataplayground3/lib/python3.5/site-packages/jax/core.py", line 592, in call_bind
outs = primitive.impl(f, *args, **params)
File "/home/u1/zach/proj/dataplayground3/lib/python3.5/site-packages/jax/interpreters/xla.py", line 400, in _xla_call_impl
@zmjjmz
zmjjmz / export_error
Created August 14, 2019 21:17
Vespa Keras tf experiment export_saved_model issues
{'error-code': 'INVALID_APPLICATION_PACKAGE',
'message': 'Invalid application package: default.default: Error loading '
'model: Could not import TensorFlow model from directory '
"'/opt/vespa/var/db/vespa/config_server/serverdb/tenants/default/sessions/175/.preprocessed/models/plike_test/tf114_export': "
"_output_shapes attribute of 'init_1' does not exist"}
@zmjjmz
zmjjmz / keras.py
Created August 14, 2019 19:22
Vespa Keras weirdness
import keras
import numpy as np
input_l = keras.Input(shape=(1,), name='input')
layer_1 = keras.layers.Dense(1, activation='relu', name='layer_1')(input_l)
output_l = keras.layers.Dense(1, activation='linear', name='output')(layer_1)
model = keras.Model(inputs=[input_l], outputs=[output_l])
model.compile(loss='mean_absolute_error', optimizer='rmsprop')
x = np.array(np.arange(1, 100000))
@zmjjmz
zmjjmz / documented_example.py
Created July 11, 2019 22:02
TF keras export usage
import tensorflow as tf
# Create a tf.keras model.
print(tf.version.VERSION)
model = tf.keras.Sequential()
model.add(tf.keras.layers.Dense(1, input_shape=[10]))
model.summary()
# Save the tf.keras model in the SavedModel format.
saved_to_path = tf.keras.experimental.export(