के लिए एलएसटीएम मॉड्यूल क्या किसी को पता है कि कैफे के लिए एक अच्छा एलएसटीएम मॉड्यूल मौजूद है या नहीं? मैंने russel91 द्वारा एक github खाते में से एक पाया लेकिन उदाहरण के साथ वेबपृष्ठ में उदाहरण और स्पष्टीकरण गायब हो गए (पूर्व में http://apollo.deepmatter.io/ -> अब यह केवल github page पर रीडायरेक्ट करता है जिसमें अब कोई उदाहरण या स्पष्टीकरण नहीं है)।कैफे
कैफे
उत्तर
मुझे पता है Jeff Donahue कैफे का उपयोग कर एलएसटीएम मॉडल पर काम किया। उन्होंने सीवीपीआर 2015 के दौरान एक अच्छा tutorial भी दिया। उनके पास आरएनएन और एलएसटीएम के साथ pull-request है।
अद्यतन: आरएनएन और एलएसटीएम सहित जेफ डोनाहु द्वारा new PR है। यह पीआर जून 2016 को मास्टर करने के लिए विलय कर दिया गया था।
वास्तव में, प्रशिक्षण आवर्ती नेट अक्सर नेट को अनलॉक करके किया जाता है। यही है, अस्थायी चरणों (नेट को अस्थायी चरणों में वजन साझा करना) पर नेट की नकल करना और अनियंत्रित मॉडल पर आगे-पिछड़े पास करना।
एलएसटीएम (या किसी अन्य इकाई) को अनलॉक करने के लिए आपको Jeff Donahue की आवर्ती शाखा का उपयोग करने की आवश्यकता नहीं है, बल्कि मॉडल को स्पष्ट रूप से अनलॉक करने के लिए NetSpec()
का उपयोग करें।
from caffe import layers as L, params as P, to_proto
import caffe
# some utility functions
def add_layer_to_net_spec(ns, caffe_layer, name, *args, **kwargs):
kwargs.update({'name':name})
l = caffe_layer(*args, **kwargs)
ns.__setattr__(name, l)
return ns.__getattr__(name)
def add_layer_with_multiple_tops(ns, caffe_layer, lname, ntop, *args, **kwargs):
kwargs.update({'name':lname,'ntop':ntop})
num_in = len(args)-ntop # number of input blobs
tops = caffe_layer(*args[:num_in], **kwargs)
for i in xrange(ntop):
ns.__setattr__(args[num_in+i],tops[i])
return tops
# implement single time step LSTM unit
def single_time_step_lstm(ns, h0, c0, x, prefix, num_output, weight_names=None):
"""
see arXiv:1511.04119v1
"""
if weight_names is None:
weight_names = ['w_'+prefix+nm for nm in ['Mxw','Mxb','Mhw']]
# full InnerProduct (incl. bias) for x input
Mx = add_layer_to_net_spec(ns, L.InnerProduct, prefix+'lstm/Mx', x,
inner_product_param={'num_output':4*num_output,'axis':2,
'weight_filler':{'type':'uniform','min':-0.05,'max':0.05},
'bias_filler':{'type':'constant','value':0}},
param=[{'lr_mult':1,'decay_mult':1,'name':weight_names[0]},
{'lr_mult':2,'decay_mult':0,'name':weight_names[1]}])
Mh = add_layer_to_net_spec(ns, L.InnerProduct, prefix+'lstm/Mh', h0,
inner_product_param={'num_output':4*num_output, 'axis':2, 'bias_term': False,
'weight_filler':{'type':'uniform','min':-0.05,'max':0.05},
'bias_filler':{'type':'constant','value':0}},
param={'lr_mult':1,'decay_mult':1,'name':weight_names[2]})
M = add_layer_to_net_spec(ns, L.Eltwise, prefix+'lstm/Mx+Mh', Mx, Mh,
eltwise_param={'operation':P.Eltwise.SUM})
raw_i1, raw_f1, raw_o1, raw_g1 = \
add_layer_with_multiple_tops(ns, L.Slice, prefix+'lstm/slice', 4, M,
prefix+'lstm/raw_i', prefix+'lstm/raw_f', prefix+'lstm/raw_o', prefix+'lstm/raw_g',
slice_param={'axis':2,'slice_point':[num_output,2*num_output,3*num_output]})
i1 = add_layer_to_net_spec(ns, L.Sigmoid, prefix+'lstm/i', raw_i1, in_place=True)
f1 = add_layer_to_net_spec(ns, L.Sigmoid, prefix+'lstm/f', raw_f1, in_place=True)
o1 = add_layer_to_net_spec(ns, L.Sigmoid, prefix+'lstm/o', raw_o1, in_place=True)
g1 = add_layer_to_net_spec(ns, L.TanH, prefix+'lstm/g', raw_g1, in_place=True)
c1_f = add_layer_to_net_spec(ns, L.Eltwise, prefix+'lstm/c_f', f1, c0, eltwise_param={'operation':P.Eltwise.PROD})
c1_i = add_layer_to_net_spec(ns, L.Eltwise, prefix+'lstm/c_i', i1, g1, eltwise_param={'operation':P.Eltwise.PROD})
c1 = add_layer_to_net_spec(ns, L.Eltwise, prefix+'lstm/c', c1_f, c1_i, eltwise_param={'operation':P.Eltwise.SUM})
act_c = add_layer_to_net_spec(ns, L.TanH, prefix+'lstm/act_c', c1, in_place=False) # cannot override c - it MUST be preserved for next time step!!!
h1 = add_layer_to_net_spec(ns, L.Eltwise, prefix+'lstm/h', o1, act_c, eltwise_param={'operation':P.Eltwise.PROD})
return c1, h1, weight_names
एक बार जब आप एक बार कदम है, तो आप यह रूप में कई बार आप चाहते हैं prototxt लेखन उतारना कर सकते हैं ...
def exmaple_use_of_lstm():
T = 3 # number of time steps
B = 10 # batch size
lstm_output = 500 # dimension of LSTM unit
# use net spec
ns = caffe.NetSpec()
# we need initial values for h and c
ns.h0 = L.DummyData(name='h0', dummy_data_param={'shape':{'dim':[1,B,lstm_output]},
'data_filler':{'type':'constant','value':0}})
ns.c0 = L.DummyData(name='c0', dummy_data_param={'shape':{'dim':[1,B,lstm_output]},
'data_filler':{'type':'constant','value':0}})
# simulate input X over T time steps and B sequences (batch size)
ns.X = L.DummyData(name='X', dummy_data_param={'shape': {'dim':[T,B,128,10,10]}})
# slice X for T time steps
xt = L.Slice(ns.X, name='slice_X',ntop=T,slice_param={'axis':0,'slice_point':range(1,T)})
# unroling
h = ns.h0
c = ns.c0
lstm_weights = None
tops = []
for t in xrange(T):
c, h, lstm_weights = single_time_step_lstm(ns, h, c, xt[t], 't'+str(t)+'/', lstm_output, lstm_weights)
tops.append(h)
ns.__setattr__('c'+str(t),c)
ns.__setattr__('h'+str(t),h)
# concat all LSTM tops (h[t]) to a single layer
ns.H = L.Concat(*tops, name='concat_h',concat_param={'axis':0})
return ns
:
यहाँ एक सरल उदाहरण है
ns = exmaple_use_of_lstm()
with open('lstm_demo.prototxt','w') as W:
W.write('name: "LSTM using NetSpec example"\n')
W.write('%s\n' % ns.to_proto())
परिणामी अनियंत्रित नेट (तीन बार चरणों के लिए)
जैसा दिखता हैसंबंधित पोस्ट पोस्ट करने के लिए धन्यवाद: http: // stackoverflow .com/q/36748063/1714410 – Shai
मैं एलएसटीएम नेटवर्क के लिए नया हूं। यह शानदार होगा, अगर कोई बताता है कि उपरोक्त उदाहरण में "मेमोरी" सेल कैसे लिखा गया है, मिटाया गया है, और पढ़ा गया है? – auro
@auro यह एक टिप्पणी के लिए बहुत व्यापक है। नए प्रश्न पूछने का प्रयास करें – Shai
- 1. कैफे
- 2. कैफे
- 3. कैफे
- 4. कैफे: पाइथन
- 5. कैफे: blobs
- 6. रेल मचान बहुवचन "कैफे"
- 7. गहरी शिक्षा - कैफे
- 8. टर्मिनल आउटपुट रीडायरेक्शन कैफे
- 9. कैफे + ओपनसीवी बिना एलएमडीबी
- 10. परीक्षण किए बिना कैफे प्रशिक्षण
- 11. कैफे | solver.prototxt मूल्य सेटिंग रणनीति
- 12. कैफे स्नैपशॉट्स:। सोल्वरस्टेट बनाम। कैफिमोडेल
- 13. संकलन कैफे सी ++ वर्गीकरण उदाहरण
- 14. कैफे सिग्मोइड क्रॉस एंट्रॉपी लॉस
- 15. कैफे में यूक्लिडियन लॉस लेयर
- 16. कैफे सिग्मोइड क्रॉसइंटरोपॉइस लेयर लॉस फ़ंक्शन
- 17. कैफे net.predict() आउटपुट यादृच्छिक परिणाम (GoogleNet)
- 18. कैफे में न्यूनतम-अधिकतम सामान्यीकरण परत
- 19. कैफे एचडीएफ 5 पिक्सेल-वार वर्गीकरण
- 20. पायथन में कस्टम कैफे परत का निर्माण
- 21. कैफे में बंधे वजन वाले ऑटो-एन्कोडर्स
- 22. RMSprop, Adam, AdaDelta परीक्षण सटीकता कैफे
- 23. सी-संगत फैशन कैफे ब्लॉब स्टोरेज में क्या मतलब है?
- 24. कैफे में एकाधिक जीपीयू का उपयोग कैसे किया जाता है?
- 25. टेंस्फोर्लो मॉडल को कैफे मॉडल में कनवर्ट करें
- 26. कैफे में दो ब्लब्स को कैसे नियंत्रित करें
- 27. कैफे में इन-प्लेस परतों का उपयोग कब करें?
- 28. कैफे 2 टेंसर <CUDAContext> असाइनमेंट, निर्माण या प्रतिलिपि
- 29. कैफे त्रुटि परत से पैरा 0 वजन की प्रतिलिपि नहीं बना सकता है, आकार मिस्चैच
- 30. आयात त्रुटि में कैफे परिणाम आयात करना: "google.protobuf.internal नामक कोई मॉड्यूल नहीं है" (आयात enum_type_wrapper)
क्या आपने इसे आजमाया? मॉड्यूल का उपयोग करने के लिए मुझे एक अच्छा विवरण नहीं मिला। एक गिथब चर्चा के ट्रैक में एक खिलौना उदाहरण था, लेकिन वास्तव में स्वयं स्पष्टीकरण नहीं (साथ ही मुझे अब और नहीं मिल रहा है)। आपके द्वारा उल्लिखित ट्यूटोरियल केवल सामान्य रूप से एलएसटीएम के बारे में बात कर रहा है। – mcExchange
@mcExchange मैंने अभी तक कोशिश नहीं की है – Shai
ट्यूटोरियल स्याही के लिए धन्यवाद। स्लाइड बहुत अच्छी हैं लेकिन वीडियो प्रस्तुति सुनने में हरा नहीं सकते हैं। http://techtalks.tv/talks/long-term-recurrent-convolutional-networks-for-visual-recognition-and-description/61594/ – auro