Skip to content

Instantly share code, notes, and snippets.

@kriskorrel-cw
kriskorrel-cw / saved_model_custom_layer.py
Created April 9, 2020 09:37
Saving a model not possible with custom layer, using different signature
from tensorflow import keras
from tensorflow.keras.layers import BatchNormalization, Dense
class BatchNormalization1(BatchNormalization):
def call(self, inputs, **kwargs):
return super(BatchNormalization1, self).call(inputs, **kwargs)
class BatchNormalization2(BatchNormalization):
@kriskorrel-cw
kriskorrel-cw / copy_tensor_bug.py
Last active June 10, 2020 07:50
MWE copy tensor bug
import numpy as np
import os
import tensorflow as tf
from tensorflow.keras.layers import Dense, Flatten
from tensorflow.keras.optimizers import Adam
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
os.environ['TF_FORCE_GPU_ALLOW_GROWTH'] = 'true'
ssh://username@192.168.1.10:22/home/username/.local/share/virtualenvs/project-1BQtdZDZ/bin/python -u /data/personal/username/deployed/project/project/bin/copy_tensor_bug.py
2020-06-10 09:49:40.096725: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2020-06-10 09:49:40.178485: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2020-06-10 09:49:40.178972: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1561] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.86GHz coreCount: 20 deviceMemorySize: 7.93GiB deviceMemoryBandwidth: 298.32GiB/s
2020-06-10 09:49:40.179163: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcudart.so.10.1
2020-06-10 09:49:40.180759: I tensorflow/stream_executor/platfo