Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
19 views
2 pages
LSTM Ref05
phamdinhkhanh - khoa hoc du lieu - mang lstm part 05
Uploaded by
tuong.nguyen
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save lstm_ref05 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
19 views
2 pages
LSTM Ref05
phamdinhkhanh - khoa hoc du lieu - mang lstm part 05
Uploaded by
tuong.nguyen
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save lstm_ref05 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 2
Search
Fullscreen
12721124, 9:52 AN hoa ge gu nchars = len(raw_text) n_vocab = 1en(chars_new) print(‘Total characters: *, n_chars) print(‘Total Vocab: *, n_vocab) Total characters: 163693, 2 Total Vocab: 33 Nhu vay sau chun héa van ban cla ching ta s& bao gbm 163693 tir va 33 ki tu. Tiép theo lé mot ham chuyén héa. mot cau thanh mét vector chi s6 cae ki ty. 1 def _encode_sen(text): 2 Fext = text-lower() 3 sen_vec = [] 4 for let in text s Af Let in chars_nen[:-2) 6 idx = chars_to_int[let] 7 else: 8 idx = chars_to_int['unk"] ° sen_vec. append( idx) 10 return sen_vec u 12x test = _encode_sen(‘ALice is a wonderful story. #") 13 print(x test) 1 [@, 11, 8, 2, 4, 29, 8, 18, 29, @, 29, 22, 14, 13, 3, 4, 17, 5, 28, 11, 29, 18, 19, 14, 17, 2 1 def _dacode_sen(vec) 2 text = [] 3 for i in vec 4 Let = int_to_chars[i] 5 ‘ext append(let) 6 text = "*.Join(text) 7 return text a 8 _decode_sen(x test) 1 ‘alice is a wonderful story. unk* 'D8 dng nhdt 46 dai du vao cho mé hin cn tao ra cdc chusi ki ty (window input) véri véi d@ da fa 100. Miye dich cia ching tala dy bdo ki ty tip theo tir 100 ki ty dBu vo. MBi mét phién du béo window input s8 dug tinh tin Ién 1k’ ty dé thu dugc cae ki ty dy bao lién tiép nhau va tir 46 ghép Iai thanh mét cau hoan chinh, hitps:phamdinhknanh github i120 18/04/22NLy thuyet_ve_mang_LSTM.him! ene12721124, 9:52 AN a hoa ge gu # prepare the datoset of input to output pairs encoded os integers seq_length = 100 datax = [ aatay = [ for i in range(@, n_chars - seq_length, 1) # Udy ra 160 Ri ty Lian trac seq_in = raw_text[i:i + seq_length # Udy ra ki ty Lin sau 108 ki ty a5 seq_out = raw_text[i + seq_length] datax.append(_encode_sen(sea_in)) dataY-append(_encode_sen(seq_out)[@]) jatterns = len(datax) otal Patterns: ", n_patterns) print( Total Patterns: 163593 'Bé 06 thé dva vao m8 hinh LSTM, dau vao x c&n duge chudn héa thanh mot ma tran 3 chitu samples, tice steps, features . Trong dé: 1. samples: Sé lrgng mu du vao (irc 56 lwgng cira s6 window 100 length). 2. time steps: 86 dai cia cra sé window chinh la s6 lurgng cdc véng lap khi duge trai phing & hinh 2 cu tric tri ph&ng mang no ron, Trong mé hinh nay time steps = 100 3. features: S6 lrgng chiéu dug ma héa cla du vao. Trong mé hinh LSTM, mBi m@t tr ho8c ki ty (ty theo ching ta lam vige vei level nao} 1uémg urge ms héa theo 2 cach théng thuéng sau day: © ma héa theo one-hot encoding 48 mét k ty (@ bal thuc hanh nay la ki ty) duge bibu didn bai mat véc to ‘one-hot «ma héa theo gid tr véc to dug Idytir mé hinh word embedding pretrain tréc a6. Cé thé la word2ve6, fasttext, ELMo, BERT... Sé lygng cae chibu theo level ki ty thuréng it hon so v6i evel ti. Trong bai nay 48 don gidn ta khong sir dung mét lop embedding 6 du a8 ning th thanh véc to ma sir dung {ruc tiép gid tr du vao 8 index cia ki ty. Do 46 s6 features = 1. 4# reshape X to be [samples, time steps, features] X.train = numpy.reshape(datax, (n_patterns, seq_length, 1)) normalize Xtrain = Xtrain / float(n_vocab) 4 one hot encode the output variable y_train = np_utils.to_categorical (¢ataY) print("X [sasples, tine steps, features] shape: ‘, X train.shape) print(‘Y shape: ", y_train.shape) X [sanples, time steps, features] shape: (163593, 108, 2) Y shape: (263593, 33) print type (x, print type. srain)) rain))
“Théng ké s6 lugng cdc ki ty theo nhém. hitps:Jphamdinhknanh github i120 18/04/22NLy thuyet_ve_mang_LSTM.him! 016
You might also like
LSTM Ref04
PDF
No ratings yet
LSTM Ref04
2 pages
Python Programming - Chapter05 - function-guiSV
PDF
No ratings yet
Python Programming - Chapter05 - function-guiSV
64 pages
Final Exam 20222
PDF
No ratings yet
Final Exam 20222
3 pages
Deeplearning - Ai Deeplearning - Ai
PDF
No ratings yet
Deeplearning - Ai Deeplearning - Ai
43 pages
Ly Thuyet Co Ban - Python - 2
PDF
No ratings yet
Ly Thuyet Co Ban - Python - 2
36 pages
On Tap Python Da
PDF
No ratings yet
On Tap Python Da
16 pages
Mamba Code
PDF
No ratings yet
Mamba Code
12 pages
Python Programming Chapter05 Function - 3200 - PDF - Gdrive.vip
PDF
No ratings yet
Python Programming Chapter05 Function - 3200 - PDF - Gdrive.vip
48 pages
Chuong 2
PDF
No ratings yet
Chuong 2
47 pages
(Description) Sentiment Analysis
PDF
No ratings yet
(Description) Sentiment Analysis
9 pages
Tim Hieu Ve Deep Learning
PDF
100% (1)
Tim Hieu Ve Deep Learning
78 pages
CT225
PDF
No ratings yet
CT225
7 pages
Python cơ bản
PDF
No ratings yet
Python cơ bản
89 pages
HK2 2017-2018 CK DapAn
PDF
No ratings yet
HK2 2017-2018 CK DapAn
8 pages
MATH
PDF
No ratings yet
MATH
6 pages
2024 11 06 10 AMh13m46s - Scan - QuickScan
PDF
No ratings yet
2024 11 06 10 AMh13m46s - Scan - QuickScan
17 pages
File Trac Nghiem
PDF
No ratings yet
File Trac Nghiem
45 pages
Chat GPT
PDF
No ratings yet
Chat GPT
12 pages
TaiLieu in Ver2
PDF
No ratings yet
TaiLieu in Ver2
2 pages
kĩ thuật lập trình
PDF
No ratings yet
kĩ thuật lập trình
27 pages
Tài Liệu System Identification Toolbox Tiếng Việt - Tài Liệu, eBook, Giáo Trình
PDF
No ratings yet
Tài Liệu System Identification Toolbox Tiếng Việt - Tài Liệu, eBook, Giáo Trình
22 pages
FinalExam S1 2018 2019
PDF
No ratings yet
FinalExam S1 2018 2019
4 pages
BT Python
PDF
No ratings yet
BT Python
7 pages
Text Classification: Dr. Nguyen Van Vinh CS Department - UET, Hanoi VNU
PDF
No ratings yet
Text Classification: Dr. Nguyen Van Vinh CS Department - UET, Hanoi VNU
50 pages
Python - CoBan
PDF
No ratings yet
Python - CoBan
5 pages
BTL2 Harmony
PDF
No ratings yet
BTL2 Harmony
9 pages
10b Dap An de Thi Tin Hoc CSP 2024
PDF
No ratings yet
10b Dap An de Thi Tin Hoc CSP 2024
3 pages
C2 2 Python DataType Operator
PDF
No ratings yet
C2 2 Python DataType Operator
18 pages
Bai Tap Lon H241
PDF
No ratings yet
Bai Tap Lon H241
4 pages
KTS
PDF
No ratings yet
KTS
60 pages
Data Structures and Algorithms Midterm Exam
PDF
No ratings yet
Data Structures and Algorithms Midterm Exam
2 pages
BÀI TẬP THỰC HÀNH BUỔI 1
PDF
No ratings yet
BÀI TẬP THỰC HÀNH BUỔI 1
15 pages
BAI THUC HANH MPHTTT (b1)
PDF
No ratings yet
BAI THUC HANH MPHTTT (b1)
25 pages
Onrnrvixul-,I1: Cau R: (3 Di6M)
PDF
No ratings yet
Onrnrvixul-,I1: Cau R: (3 Di6M)
39 pages
Tiet 56 Lam Viec Voi Day So Hot (Compatibility Mode)
PDF
No ratings yet
Tiet 56 Lam Viec Voi Day So Hot (Compatibility Mode)
11 pages
Giáo Trình Stable Diffusion Cơ Bản - Hưng AI Creative Art
PDF
100% (1)
Giáo Trình Stable Diffusion Cơ Bản - Hưng AI Creative Art
17 pages
6657dd3b33d15658040972dd Paper Presentation
PDF
No ratings yet
6657dd3b33d15658040972dd Paper Presentation
9 pages
Fortran Ch2
PDF
No ratings yet
Fortran Ch2
17 pages
CamScanner 09-09-24 17.22
PDF
No ratings yet
CamScanner 09-09-24 17.22
3 pages
Untitled Notebook 1
PDF
No ratings yet
Untitled Notebook 1
4 pages
Phần 11 - Xử lý File
PDF
No ratings yet
Phần 11 - Xử lý File
3 pages
Giáo Trình Stable Diffusion Cơ Bản - Hưng AI Thực Chiến - 240115004
PDF
No ratings yet
Giáo Trình Stable Diffusion Cơ Bản - Hưng AI Thực Chiến - 240115004
29 pages
2 Ptit-Static-Analys-Linux
PDF
No ratings yet
2 Ptit-Static-Analys-Linux
6 pages
124 NguyenThiTraMy Bai2C1 Code
PDF
No ratings yet
124 NguyenThiTraMy Bai2C1 Code
6 pages
Baitapcoban Py
PDF
No ratings yet
Baitapcoban Py
2 pages
B8 CBB Nguyễn Hữu Quí
PDF
No ratings yet
B8 CBB Nguyễn Hữu Quí
13 pages
Code
PDF
No ratings yet
Code
4 pages
Tin HSG
PDF
No ratings yet
Tin HSG
3 pages
Ngay 1 2018
PDF
No ratings yet
Ngay 1 2018
5 pages
Ghichu
PDF
No ratings yet
Ghichu
2,936 pages
Neural 123
PDF
No ratings yet
Neural 123
6 pages
One Two Three p1 p2 p3: A) Con Trá
PDF
No ratings yet
One Two Three p1 p2 p3: A) Con Trá
6 pages
Bao Cao Bai Tap Buoi 2
PDF
No ratings yet
Bao Cao Bai Tap Buoi 2
8 pages
Embedded Systems - Chapter 8
PDF
No ratings yet
Embedded Systems - Chapter 8
50 pages
It006 CK1 1819
PDF
No ratings yet
It006 CK1 1819
6 pages
(IPPA233277) w08-w09-c06 - Class (Done)
PDF
No ratings yet
(IPPA233277) w08-w09-c06 - Class (Done)
33 pages
GK E10
PDF
No ratings yet
GK E10
4 pages
SGK BT Chuyên Tin Quyển 2
PDF
No ratings yet
SGK BT Chuyên Tin Quyển 2
176 pages
Exercise Data Analysis
PDF
No ratings yet
Exercise Data Analysis
25 pages