Detailed instructions to establish the LSTM----The voice direction of training your own data with Keras

Source: Internet
Author: User
Tags dnn keras

Recently in the study of using Keras to implement a lstm to train their own data (lstm the basic principles of self-tuition), the first of their own data with the DNN to train, and then to the LSTM, because the input is not the same, so some burn, DNN input format is input: (Samples,dim), is a two-dimensional data, and the input format of lstm: (Samples,time_step,dim) is three-dimensional, so, first understand how to convert DNN input into lstm input, I will explain in detail below.

DNN input is a frame, each frame of the input corresponds to an output, if said, you have n sentence, the frame number of each sentence is not the same, if there is a total of M-frame, after a certain processing, the dimension is Di, the data frames are merged together to form a (M,di) matrix, as the input of DNN, and (M, DL) as a DNN label for training, this completes the DNN training, next we want to convert this (M,DI) data into lstm data, training lstm.

First of all we need to know that the input of lstm is a sequence, that is, a series of continuous frames, which is the biggest difference with DNN input data, and now according to the above hypothesis, each sentence length is different, so now we deal with the input of LSTM is a variable-length sequence, the reference is HTTP// Www.cnblogs.com/leeshum/p/6089286.html, this is very clear, since it is variable length, we will have to fill the data into fixed length, the specific operation is as follows.

Find the longest sentence in all sentences, if it is 200 frames, then we will all the sentences are 200 frames so long, the specific method of their own choice, matlab and Python can be easily implemented, the sentences are 200 frames, the corresponding label will be 200 frames, These sentences are then combined into data similar to DNN input (200*num_sentence,dim), and now lstm input is actually in sentence units, lstm input form (Samples,time_step,dim) samples is the number of sentences , Time_step is 200, so at the time of data processing, you put this (200*num_sentence,dim) data reshape into (Num_sentence,200,dim), this input is lstm input, At this time the form of output to be converted to the corresponding form (Num_sentence,200,dim_label), in training, batch size is the number of sentences, reshape completed, before the input lstm need to filter out the data, specifically see HTTP// Www.cnblogs.com/leeshum/p/6089286.html, here is very clear, now, lstm input and output are done, can go to build their own lstm to train.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.