第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在給定的 DL 模型中調(diào)查特征的重要性和權(quán)重演變

在給定的 DL 模型中調(diào)查特征的重要性和權(quán)重演變

慕勒3428872 2021-10-12 15:23:51
對于比平時更長的介紹,我深表歉意,但對于這個問題很重要:我最近被分配到一個現(xiàn)有項目上工作,該項目使用 Keras+Tensorflow 創(chuàng)建一個完全連接的網(wǎng)絡(luò)。總的來說,該模型有 3 個全連接層,有 500 個神經(jīng)元,并有 2 個輸出類。第一層有 500 個神經(jīng)元,它們連接到 82 個輸入特征。該模型用于生產(chǎn)并每周重新訓(xùn)練,使用由外部來源生成的本周信息。設(shè)計模型的工程師不再在這里工作,我正在嘗試逆向工程并了解模型的行為。我為自己定義的幾個目標是:了解特征選擇過程和特征重要性。了解并控制每周的再培訓(xùn)過程。為了嘗試回答這兩個問題,我實施了一個實驗,我用兩個模型輸入我的代碼:一個來自前一周,另一個來自本周:import pickleimport numpy as npimport matplotlib.pyplot as pltfrom keras.models import model_from_jsonpath1 = 'C:/Model/20190114/'path2 = 'C:/Model/20190107/'model_name1 = '0_10.1'model_name2 = '0_10.2'models = [path1 + model_name1, path2 + model_name2]features_cum_weight = {}然后我取每個特征并嘗試對將其連接到第一個隱藏層的所有權(quán)重(它們的絕對值)求和。通過這種方式,我創(chuàng)建了兩個包含 82 個值的向量:for model_name in models:    structure_filename = model_name + "_structure.json"    weights_filename = model_name + "_weights.h5"    with open(structure_filename, 'r') as model_json:        model = model_from_json(model_json.read())        model.load_weights(weights_filename)    in_layer_weights = model.layers[0].get_weights()[0]    in_layer_weights = abs(in_layer_weights)    features_cum_weight[model_name] = in_layer_weights.sum(axis=1)然后我使用 MatplotLib 繪制它們:# Plot the Evolvement of Input Neuron Weights:keys = list(features_cum_weight.keys())weights_1 = features_cum_weight[keys[0]]weights_2 = features_cum_weight[keys[1]]fig, ax = plt.subplots(nrows=2, ncols=2)width = 0.35  # the width of the barsn_plots = 4batch = int(np.ceil(len(weights_1)/n_plots))for i in range(n_plots):    start = i*(batch+1)    stop  = min(len(weights_1), start + batch + 1)    cur_w1 = weights_1[start:stop]    cur_w2 = weights_2[start:stop]    ind = np.arange(len(cur_w1))    cur_ax = ax[i//2][i%2]    cur_ax.bar(ind - width/2, cur_w1, width, color='SkyBlue', label='Current Model')    cur_ax.bar(ind + width/2, cur_w2, width, color='IndianRed', label='Previous Model')    cur_ax.set_ylabel('Sum of Weights')    cur_ax.set_title('Sum of all weights connected by feature')    cur_ax.set_xticks(ind)    cur_ax.legend()    cur_ax.set_ylim(0, 30)plt.show()
查看完整描述

1 回答

?
米脂

TA貢獻1836條經(jīng)驗 獲得超3個贊

這種類型的扣除并不完全正確。特征之間的組合不是線性的。確實,如果嚴格為 0 沒有關(guān)系,但它可能會以另一種方式在另一個深層重新組合。


如果您的模型是線性的,那將是正確的。事實上,這就是 PCA 分析的工作原理,它通過協(xié)方差矩陣搜索線性關(guān)系。特征值將指示每個特征的重要性。


我認為有幾種方法可以證實你的懷疑:


消除您認為不重要的特征,再次訓(xùn)練并查看結(jié)果。如果是相似的,那么你的懷疑是正確的。


應(yīng)用當前模型,舉一個例子(我們稱之為樞軸)來評估和顯著改變你認為不相關(guān)的特征并創(chuàng)建許多例子。這適用于多個樞軸。如果結(jié)果相似,則該字段應(yīng)該無關(guān)緊要。示例(我認為第一個功能無關(guān)緊要):


data = np.array([[0.5, 1, 0.5], [1, 2, 5]])

range_values = 50


new_data = []

for i in range(data.shape[0]):

    sample = data[i]

    # We create new samples 

    for i in range (1000):

        noise = np.random.rand () * range_values

        new_sample = sample.copy()

        new_sample[0] += noise

        new_data.append(new_sample)


查看完整回答
反對 回復(fù) 2021-10-12
  • 1 回答
  • 0 關(guān)注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號