Custom Loss in Keras
(from Naive to Example-wise Weighted)

本篇介紹使用Keras時如何客製化損失函數(custom Loss function),從簡單至複雜的客製化程度介紹。順道一提,因為工作太忙拖稿了有點久,加上本來是因應自己需求面example-wise weighted custom loss,但發現這樣文章不通順,還是從簡易的built-in loss慢慢延伸到複雜的比較好吸收。 文章會按照以下的順序介紹,希望閱讀者能夠比較好吸收: Built-in Loss Function Custom Loss Function (Mirror)...

5 minute read

Pitfall in Lambda

嗨,大家好,這篇又再談談我遇到的另外一個問題:在建置機器學習模型中需要測試多個客製化的量測函式 (實際的問題我留在下一篇再來講),本篇以簡單的例子呈現原始問題的所在: 首先,假設實驗裡面需要測量二維向量的weighted inner product,定義一組函式如下,並賦予三組權重W來測試一下: def w_metric(X, Y, W): return sum(x*y*w for x, y, w...

4 minute read

Logical Not Operation in Numpy

建置預測模型過程中,我把所面臨的問題簡化成分類問題。首先,預處理ground truth data,並將它轉成one-hot vector。 以下使用簡單的範例: d = {'d1': [10, 20, 30, 40, 50, 60], 'd2':...

3 minute read