عنوان: شبکه های تراکم مخلوط (MDN) برای تخمین توزیع و عدم قطعیت
این مخزن مجموعهای از نوتبوکهای Jupyter است که برای حل بسیاری از مسائل در نظر گرفته شده است که در آن میخواهیم توزیع احتمال را با استفاده از شبکه تراکم مخلوط برای اجتناب از مسئله NaN و سایر مسائل مشتق شده از مدل پیشنهاد شده توسط Bishop, C. M. (1994) پیشبینی کنیم. دومین هدف اصلی این مخزن جستجوی راه هایی برای پیش بینی عدم قطعیت با استفاده از شبکه های عصبی مصنوعی است.
اجرای شبکههای تراکم مخلوط (MDN) برای تخمین توزیع و عدم قطعیت با استفاده از Keras (TensorFlow)
این پروژه شامل کل کد، تا 20.1.2017، نتیجه پایان نامه نهایی کارشناسی ارشد در مقطع کارشناسی ارشد هوش مصنوعی به راهنمایی دکتر جوردی ویتریا است.
نمایش مدل شبکه تراکم مخلوط. خروجی شبکه عصبی پیشخور پارامترها را در مدل چگالی مخلوط تعیین میکند. بنابراین، مدل چگالی مخلوط، تابع چگالی احتمال شرطی متغیرهای هدف مشروط بر بردار ورودی شبکه عصبی را نشان میدهد.
ترفندها و تکنیک های اجرا شده
- ترفند Log-sum-exp.
- تابع نمایش ELU+1 برای پارامتر مقیاس واریانس پیشنهاد شده توسط ما در پایان نامه کارشناسی ارشد که پس از انتشار آن را پیوند خواهم داد.
- برش مقدار پارامتر ضریب اختلاط.
- میانگین log احتمال گاوسی پیشنهاد شده توسط Bishop.
- میانگین لاگ احتمال لاپلاس پیشنهاد شده توسط ما در پایان نامه کارشناسی ارشد که پس از انتشار آن را پیوند خواهم داد.
- روش علامت گرادیان سریع برای تولید آموزش خصمانه پیشنهاد شده توسط Goodfellow و همکاران.
- نسخه اصلاح شده آموزش دشمن پیشنهاد شده توسط نوکلند.
- برآورد عدم قطعیت پیشبینیکننده ساده و مقیاسپذیر با استفاده از اجرای Deep Ensembles پیشنهاد شده توسط Lakshminarayanan و همکاران.
برخی از الگوریتم های Keras استفاده شده:
- الگوریتم بهینه سازی RMSProp
- الگوریتم بهینه سازی آدم
- برش گرادیان
- نرمال سازی دسته ای
قابلیت های تجسم پیاده سازی شده
- اجرای عمومی برای تجسم میانگین و واریانس (به عنوان نوار خطا) توزیع با حداکثر ضریب اختلاط MDN.
- اجرای عمومی برای تجسم میانگین و واریانس (به عنوان نوار خطا) همه توزیعهای MDN.
- اجرای عمومی برای تجسم تمام تابع چگالی احتمال به عنوان یک گرافیک حرارتی برای مسائل دو بعدی.
- اجرای عمومی برای تجسم سطح اصلی سه بعدی و تجسم میانگین توزیع مخلوط از طریق یک فرآیند نمونه برداری.
- تجسم مجموعه داده های متخاصم که در پایان نامه پیشنهاد شده است.
پیاده سازی
#Import of the TensorFlow and definition of the control_flow_ops variable import tensorflow as tf tf.python.control_flow_ops = tf #GPU Memory allocation on demand (Remove comments if necessary) ##config = tf.ConfigProto() ##config.gpu_options.allow_growth=True ##sess = tf.Session(config=config) #Import of TensorFlow backend of Keras from keras import backend as K #Some other imports import os import numpy as np from pandas.io.parsers import read_csv from sklearn.utils import shuffle import random from datetime import datetime
#Imports of the Keras library parts we will need from keras.models import Sequential,Graph from keras.layers.core import Dense, Dropout from keras.callbacks import History from keras.layers.recurrent import LSTM from keras.models import model_from_json from keras.regularizers import l2, activity_l2 from keras.objectives import mean_absolute_error #Definition of the ELU+1 function #With some margin to avoid problems of instability from keras.layers.advanced_activations import ELU def elu_modif(x, a=1.): e=1e-15 return ELU(alpha=a)(x)+1.+e c = 1 #The number of outputs we want to predict m = 1 #The number of distributions we want to use in the mixture #Note: The output size will be (c + 2) * m def log_sum_exp(x, axis=None): """Log-sum-exp trick implementation""" x_max = K.max(x, axis=axis, keepdims=True) return K.log(K.sum(K.exp(x - x_max), axis=axis, keepdims=True))+x_max def mean_log_Gaussian_like(y_true, parameters): """Mean Log Gaussian Likelihood distribution Note: The 'c' variable is obtained as global variable """ components = K.reshape(parameters,[-1, c + 2, m]) mu = components[:, :c, :] sigma = components[:, c, :] alpha = components[:, c + 1, :] alpha = K.softmax(K.clip(alpha,1e-8,1.)) exponent = K.log(alpha) - .5 * float(c) * K.log(2 * np.pi) \ - float(c) * K.log(sigma) \ - K.sum((K.expand_dims(y_true,2) - mu)**2, axis=1)/(2*(sigma)**2) log_gauss = log_sum_exp(exponent, axis=1) res = - K.mean(log_gauss) return res def mean_log_LaPlace_like(y_true, parameters): """Mean Log Laplace Likelihood distribution Note: The 'c' variable is obtained as global variable """ components = K.reshape(parameters,[-1, c + 2, m]) mu = components[:, :c, :] sigma = components[:, c, :] alpha = components[:, c + 1, :] alpha = K.softmax(K.clip(alpha,1e-2,1.)) exponent = K.log(alpha) - float(c) * K.log(2 * sigma) \ - K.sum(K.abs(K.expand_dims(y_true,2) - mu), axis=1)/(sigma) log_gauss = log_sum_exp(exponent, axis=1) res = - K.mean(log_gauss) return res def scoring_rule_adv(y_true, y_pred): """Fast Gradient Sign Method (FSGM) to implement Adversarial Training Note: The 'graphADV' pointer is obtained as global variable """ # Compute loss #Note: Replace with 'mean_log_Gaussian_like' if you want a Gaussian kernel. error = mean_log_LaPlace_like(y_true, y_pred) # Craft adversarial examples using Fast Gradient Sign Method (FGSM) # Define gradient of loss wrt input grad_error = K.gradients(error,graphADV.input) #Minus is on error function # Take sign of gradient, Multiply by constant epsilon, Add perturbation to original example to obtain adversarial example #Sign add a new dimension we need to obviate epsilon = 0.08 adversarial_X = K.stop_gradient(graphADV.input + epsilon * K.sign(grad_error)[0]) # Note: If you want to test the variation of adversarial training # proposed by XX, eliminate the following comment character # and comment the previous one. ##adversarial_X = graphADV.input + epsilon * K.sign(grad_error)[0] adv_output = graphADV(adversarial_X) #Note: Replace with 'mean_log_Gaussian_like' if you want a Gaussian kernel. adv_error = mean_log_LaPlace_like(y_true, adv_output) return 0.3 * error + 0.7 * adv_error #Definition of 3 stacked dense layers followed by Mixture Density block. # This initial feed-forward neural network could be as you want. graph = Graph() graph.add_input(name='input', input_shape=(12,)) graph.add_node(Dense(500, activation='relu'), name='dense1_1', input='input') graph.add_node(Dropout(0.25), name='drop1_1', input='dense1_1') graph.add_node(Dense(500, activation='relu'), name='dense2_1', input='drop1_1') graph.add_node(Dropout(0.25), name='drop2_1', input='dense2_1') graph.add_node(Dense(500, activation='relu'), name='dense3_1', input='drop2_1') graph.add_node(Dropout(0.25), name='drop3_1', input='dense3_1') graph.add_node(Dense(output_dim=500, activation="relu"), name='FC1', input='drop3_1') graph.add_node(Dense(output_dim=c*m), name='FC_mus', input='FC1') graph.add_node(Dense(output_dim=m, activation=elu_modif), name='FC_sigmas', input='FC1') #K.exp, W_regularizer=l2(1e-3) graph.add_node(Dense(output_dim=m, activation='softmax'), name='FC_alphas', input='FC1') graph.add_output(name='output', inputs=['FC_mus','FC_sigmas', 'FC_alphas'], merge_mode='concat',concat_axis=1) graphADV = graph #Note 1: 'scoring_rule_adv' by 'mean_log_Gaussian_like' or # 'mean_log_LaPlace_like' depending on your needs. #Note 2: Replace 'rmsprop' by 'adam' depending on your needs. graph.compile('rmsprop', {'output':scoring_rule_adv})
پروژه شامل فایل پایان نامه به انگلیسی، فایل پاورپوینت ارائه، فایل کامل شبیه سازی Keras / TensorFlow می باشد.
پروژه مشابه دارید؟
برای ثبت سفارش در سیمیا می توانید از طریق اپلیکیشن سیمیا، یا فرم ثبت سفارش در سایت اقدام کرده و یا از طریق ایمیل، واتساپ، تلگرام و اینستاگرام اقدام نمایید.
اپلیکیشن سیمیا را از بازار و مایکت دانلود کنید.
سریع ترین راه پاسخگویی سیمیا، واتساپ می باشد. لینک واتساپ، اینستاگرام و تلگرام در پایین سایت وجود دارد.
نشانی ایمیل سیمیا simiya_ht@yahoo.com می باشد.
از برقراری تماس برای هماهنگی پروژه خودداری کنید، حجم بالای سفارشات به ما اجازه نمی دهد تا از طریق تلفن پاسخگوی شما عزیزان باشیم، حتما درخواست خود را به صورت مکتوب و از طریق یکی از راه های ذکر شده فوق ارسال نمایید، درخواست خود را به طور کامل و با تمام فایل ها و توضیحات لازم ارسال نمایید تا مدت زمان بررسی آن به حداقل برسد. پس از تعیین کارشناس، در اسرع وقت به شما پاسخ می دهیم.
نقد و بررسیها
هیچ دیدگاهی برای این محصول نوشته نشده است.