are you me?    id passwd

status  

 sleepy

picture

 

 thinking

calender

Windows 10 시작버튼 고장시 - 컴퓨터

in powershell
$manifest = (Get-AppxPackage Microsoft.WindowsStore).InstallLocation + '\AppxManifest.xml' ; Add-AppxPackage -DisableDevelopmentMode -Register $manifest

written time : 2021-03-20 16:59:16.0

Sm520 수리 - 자동차

라디에이터

written time : 2021-03-02 17:52:04.0

tensorflow operations (matmul vs einsum, maximum vs maxout) - 컴퓨터

# the results from einsum and matmul (or multiply) differ but the difference can be negligible.

# maxout operation of tensorflow_addons returns exactly the same results of tf.maximum.

import tensorflow as tf
import tensorflow_addons as tfa

batch = 50
seq_len = 100
in_h = 60
out_h = 30
in_d = 20
out_d = 10

emb = tf.random.normal([batch, seq_len, in_h, in_d], stddev=0.1)
wgt = tf.random.normal([1, 1, in_h, out_h, out_d, in_d], stddev=0.1)
v = tf.random.normal([batch, 1, out_h, out_d, 1], stddev=0.1)

caps1_ex = tf.expand_dims(tf.expand_dims(emb, -1), 3)
caps1_ex_tiled = tf.tile(caps1_ex, [1, 1, 1, out_h, 1, 1])
u_hats = tf.matmul(tf.tile(wgt, [batch, seq_len, 1, 1, 1, 1]), caps1_ex_tiled)
naive_u_hats = tf.reshape(u_hats, [batch, seq_len, in_h, out_h, out_d, 1])

u_hat = naive_u_hats[:, 1, :, :, :, :]
naive_b = tf.matmul(u_hat, tf.tile(v, [1, in_h, 1, 1, 1]), transpose_a=True)
c = tf.nn.softmax(naive_b, axis=2)
naive_s = tf.multiply(c, u_hat)

naive_u_hats = tf.squeeze(naive_u_hats)
naive_b = tf.squeeze(naive_b)
naive_s = tf.squeeze(naive_s)

#naive_u_hats, naive_b, naive_s
wgt = tf.squeeze(wgt)
v = tf.squeeze(v)

u_hats = tf.einsum("ijkl,bsil->bsijk", wgt, emb)
einsum_u_hats = tf.reshape(u_hats, [batch, seq_len, in_h, out_h, out_d])
u_hat = einsum_u_hats[:, 1, :, :, :]
einsum_b = tf.einsum("biod,bod->bio", u_hat, v)
c = tf.nn.softmax(einsum_b, axis=2)
einsum_s = tf.einsum("bmi,bmij->bmij", c, u_hat)

tf.print(tf.reduce_sum(tf.abs(einsum_u_hats) - tf.abs(naive_u_hats))) # -4.99396774e-05
tf.print(tf.reduce_sum(tf.abs(einsum_b) - tf.abs(naive_b))) # -1.51097353e-07
tf.print(tf.reduce_sum(tf.abs(einsum_s) - tf.abs(naive_s))) # -2.60405955e-07

dense = tf.keras.layers.Dense(units=out_h)
ecs = tf.keras.layers.Conv2D(filters=50, kernel_size=(3, 3),
activation='linear', padding='same', strides=1)
mo = tfa.layers.Maxout(num_units=25, axis=-1)

emb = tf.expand_dims(dense(tf.reshape(emb, [batch, seq_len, in_h * in_d])), -1)
emb = ecs(emb)
y_maxout=mo(emb)
y_maximum=tf.maximum(emb[:,:,:,:25],emb[:,:,:,25:])

tf.print(tf.reduce_sum(tf.abs(y_maxout) - tf.abs(y_maximum))) # 0

written time : 2020-12-03 07:37:20.0
...  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |  ...