Skip to content

Instantly share code, notes, and snippets.

View UrusuLambda's full-sized avatar

Urusu Lambda UrusuLambda

View GitHub Profile
@UrusuLambda
UrusuLambda / mnist-get-feature-extraction-part-keras.py
Created August 14, 2020 09:25
How to get Intermediate / middle output in mnist output
feature_extraction_model = tf.keras.Model(inputs=model.inputs, outputs=model.get_layer("dense_2").output)
feature_extraction_output = feature_extraction_model.predict(test_images)
@UrusuLambda
UrusuLambda / mnist-tensorflow-keras-version-get-intermedial-layer-output.py
Created August 14, 2020 09:24
This is sample for mnist. Get intermediate output for tensorflow keras
!pip install -q tensorflow-gpu==2.0.0-rc1
import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras import datasets, layers, models
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.x
except Exception:
print("Failed to load 2.X")
@UrusuLambda
UrusuLambda / mnist-tensorflow-version-get-intermediate layer.py
Created August 14, 2020 09:19
Mnist Get intermediate layer output from model
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.2
except Exception:
print("Failed to load 2.2")
!pip install -q tensorflow-gpu
from __future__ import absolute_import, division, print_function
@UrusuLambda
UrusuLambda / mnist-get-feature-extraction-part.py
Created August 14, 2020 09:08
How to get intermediate value in TensorFlow2. It is very easy to write it.
# This is Feature Extraction Part of conv net
def feature_extraction_part_conv_net(x):
x = tf.reshape(x, [-1, 28, 28, 1])
conv1 = conv2d(x, weights['wc1'], biases['bc1'])
conv1 = maxpool2d(conv1, k=2)
conv2 = conv2d(conv1, weights['wc2'], biases['bc2'])
conv2 = maxpool2d(conv2, k=2)
fc1 = tf.reshape(conv2, [-1, weights['wd1'].get_shape().as_list()[0]])
@UrusuLambda
UrusuLambda / mnist-tensorflow-keras-l2-constrain-loss.py
Last active August 12, 2020 14:06
This is a l2 constrain loss function version of tensorlow-keras's mnist demo. You need to use L2ConstrainLayer if you want to train scale coefficient alpha too.
#Because I use this in colab, there some colab commands... sorry about that.
!pip install -q tensorflow-gpu==2.0.0-rc1
import tensorflow as tf
import tensorflow.keras.backend as K
from tensorflow.keras import datasets, layers, models
try:
# %tensorflow_version only exists in Colab.
%tensorflow_version 2.x
except Exception:
@UrusuLambda
UrusuLambda / simple-horizon-centering-child-div-by-display-flex.html
Created June 13, 2020 04:51
horizontal centering for child div element by display flex
<html>
<head>
</head>
<body>
<style>
.parent-just-for-vis{
width:700px;
height:300px;
background-color:black;
}
@UrusuLambda
UrusuLambda / simple-horizon-centering-child-div-by-margin-auto.html
Created June 13, 2020 04:48
child div horizontal centering by margin auto example
<html>
<head>
</head>
<body>
<style>
.parent-just-for-vis{
width:700px;
height:300px;
background-color:black;
}
@UrusuLambda
UrusuLambda / simple-centering-child-div-by-table.html
Last active June 13, 2020 04:41
centering div by table vertical align middle
<html>
<head>
</head>
<body>
<style>
.parent-just-for-vis{
width:700px;
height:300px;
background-color:black;
}
@UrusuLambda
UrusuLambda / simple-centering-child-div-by-flex.html
Created June 13, 2020 04:27
centering div by display flex
<html>
<head>
</head>
<body>
<style>
.parent-just-for-vis{
width:700px;
height:300px;
background-color:black;
}
<html>
<head>
<title>JavaScript Hieroglyph Programming</title>
</head>
<body>
<div id="helloworld"></div>
<script type="text/javascript">
var 𓆎𓅓𓏏𓊖 = "Egypt";
console.log(𓆎𓅓𓏏𓊖);
document.getElementById("helloworld").textContent = 𓆎𓅓𓏏𓊖;