Automatic travel route planning method based on probability model
Through the automatic travel route planning method based on probability model, the use of historical data to generate travel route word elements and time series, which solves the problem that the existing system cannot meet personalized needs and data collection difficulties, and realizes efficient and easy-to-maintain travel route recommendations .
Patent Information
- Application Number
- CN202411104980.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-19
AI Technical Summary
The existing tourism route recommendation system cannot meet the needs of tourists' personalized preferences and dynamic adjustment of itinerary time, and the complex design requires a large amount of geographical location and transportation mode data, which leads to difficulty in data collection and model training and maintenance.
Using the automatic travel route planning method based on probability model, the word sequence and time series are generated through historical travel itinerary data, the encoder and decoder are constructed, and the conditional probability is calculated using the fusion embedding layer, attention layer and convolutional layer to generate the travel route Word vector, implement route recommendation.
Route recommendations are generated without interacting with the real world. Later maintenance does not require real-life adjustments. Only regular updates are required to maintain model timeliness, and model parameters and calculation amounts are greatly reduced.
Smart Images

Figure CN118982440A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of tourism application, and in particular relates to an automatic tourism route planning method based on a probability model. Background Art
[0002] Self-guided tours require a lot of preparation in advance, a lot of information to be consulted and itinerary planning, which is extremely cumbersome for tourists.
[0003] There are two existing travel route recommendation systems: (1) Using a single travel route recommendation cannot meet tourists’ individual preferences, travel time, and the need to dynamically adjust itineraries.
[0004] (2) Comprehensive tourism recommendation systems, based on symbolic systems and non-intelligent algorithms, usually map real-world attractions and road networks to virtual maps, and then design algorithms to calculate recommended routes based on the virtual maps. Although this method can meet the requirements of tourists, it is complex to design and requires precise measurement and modeling capabilities. In addition, a large amount of data such as geographic location, transportation methods, and road network structure is required during development and design, which brings great difficulties to data collection and model training. It also needs to be updated in real time according to changes in the actual situation, which brings difficulties to the construction and subsequent maintenance and update of the system. Summary of the invention
[0005] In order to solve the above problems, the present invention provides a method for automatically planning a tourist route based on a probability model. The specific technical solution is as follows: A method for automatically planning a tourist route based on a probability model comprises the following steps: S1. Generate word sequence based on the name of scenic spot according to the historical text data of real travel itinerary, and generate time sequence based on the time period corresponding to the scenic spot; S2. Set query conditions, the query conditions including target time period information and route preference type information; S3. Build a probability model and obtain the travel route through the probability model; The probability model includes an encoder and a decoder; the encoder includes a fusion embedding layer, a first attention layer, a first 1-dimensional convolutional layer and a first fully connected layer connected in sequence; the decoder includes a second attention layer, a third attention layer, a second 1-dimensional convolutional layer and a second fully connected layer connected in sequence; The query condition is embedded into the encoder through a fusion embedding layer, and a query vector is obtained after feature extraction, encoding, and full connection embedding; after the query vector passes through the first attention layer, the first 1D convolutional layer, and the first fully connected layer, an encoded feature vector is output, and is input into the decoder through the third attention layer; a decoding feature vector is obtained based on a word sequence and a time series, and the decoding feature vector is input into the decoder through the second attention layer; the decoder combines the word sequence, the time series, and the encoded feature vector, calculates the conditional probability through a mutual attention mechanism, and obtains a word vector of the travel route.
[0006] Furthermore, the method for obtaining a decoding feature vector based on a word sequence and a time series is as follows: a parallel text embedding layer and a time series embedding layer are set to embed the word sequence and the time series respectively to obtain a word vector corresponding to the word sequence and a time series vector corresponding to the time series; the word vector and the time series vector are vectors of the same type and are integrated into a decoding feature vector through a bitwise addition operation.
[0007] Furthermore, the text embedding layer uses a learnable vocabulary to embed the generated word unit sequence; initializes the learnable vocabulary, and randomly initializes the encoding value of each word unit in the vocabulary, and the encoding value is trained and updated together with the network; Furthermore, the calculation formula of the time series vector is: ;in, represents a time series, represents the weight matrix of the temporal embedding layer. The weight matrix is randomly initialized using a standard normal distribution N(0,1). Indicates the corresponding bias.
[0008] Furthermore, the calculation formula of the query vector is: ;in, X represents the query vector, q Indicates the query condition. represents the weight matrix of the fused embedding layer. The weight matrix is randomly initialized using a standard normal distribution N(0,1). Indicates the corresponding bias.
[0009] Furthermore, the method of outputting the encoded feature vector after the query vector passes through the first attention layer, the first 1-dimensional convolutional layer and the first fully connected layer comprises the steps of: S311. Query vector X The three initialization matrices of each attention head in the first attention layer are calculated to obtain the attention head in the first attention layer. Q vector, K vector, V vector; S312. Based on the Q vector of the attention head in the first attention layer, K vector, V Vector, calculate the attention score for each attention head and normalize it to obtain the normalized vector; S313. Concatenate the normalized vectors of each attention head of the first attention layer to obtain an attention vector Z; S314. After performing residual connection and normalization operation on the attention vector Z and the original input, a dimensionality reduction operation is performed, and then a normalization operation is performed to obtain the encoded feature vector.
[0010] Furthermore, steps S311 to S314 specifically include: S311. The first attention layer has eight attention heads, each with three initialization matrices. , and , the query vector X Calculate with the matrix respectively to obtain the attention head in the first attention layer Q vector, K vector, V vector: , , ; (1) in, , and All are learnable matrices; Q 1. K 1. V 1 represents the attention head in the first attention layer Q vector, K vector, V vector; S312. Calculate the attention score and normalize it: ; (2) in Z i represents the normalized vector of the first attention layer’s attention head; Representation vector The dimension of express The transposed matrix of .
[0011] S313. Concatenate the normalized vectors of each attention head in the first attention layer to obtain the attention vector Z : ; (3) Among them, Z1 to Z8 represent the normalized vectors obtained by the eight attention heads of the first attention layer through step S312; S314. Attention vector Z With the original input D Perform residual connection and standardize to get the attention vector , as the input of the first fully connected layer: ; (4) in, Indicates standardized operation; The first 1D convolutional layer focuses on the attention vector Perform dimensionality reduction operations, specifically: ; (5) Among them, O represents the vector after dimensionality reduction operation, represents 1D convolution, represents the convolution kernel parameters, represents the corresponding bias; The output of the first fully connected layer is residually connected to the input, and the output of the first fully connected layer is standardized: ; (6) Among them, P represents the vector after the normalization operation, represents the weight matrix of the first fully connected layer, Represents the corresponding bias, and Relu represents the activation function.
[0012] Furthermore, the decoder combines the word sequence, the time series and the encoded feature vector, calculates the conditional probability through the mutual attention mechanism, and the method for obtaining the word vector of the travel route includes the steps of: S321. Obtain word vectors based on word sequence The time series vector obtained based on the time series Add the corresponding elements in to get the vector E ; S322. Based on the vector E and the three initialization matrices of the attention head in the second attention layer, obtain the attention head in the second attention layer Q vector, K vector, V vector; calculate the attention score for each attention head in the second attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads in the second attention layer to obtain an attention vector U ; The attention vector U With word vector Perform residual connection and normalization to obtain the attention vector ; S323. Based on attention vector , encoding feature vector And the initialization matrix of the attention head in the third attention layer, get the initialization matrix of the attention head in the third attention layer Q vector, K vector, V vector; calculate the attention score for each attention head of the third attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads of the third attention layer to obtain an attention vector D ; S324. Attention vector D With attention vector After residual connection and standardization, dimensionality reduction is performed, and then standardization is performed to obtain the feature vector R .
[0013] Furthermore, steps S321 to S324 specifically include: S321. Obtain word vectors based on word sequence The time series vector obtained based on the time series Add the corresponding elements in to get the vector E : ; S322. The second attention layer includes eight attention heads, and the vector E The attention vector is obtained through the second multi-head attention layer ; in, , U 1 to U 8 represents the normalized vectors of the eight attention heads in the second attention layer; , U i represents the normalized vector of the attention head of the second attention layer, 1≤i≤8; Q 2. K 2. V 2 respectively represent the attention heads in the second attention layer Q vector, K vector, V vector, Representation vector K Dimension 2, express K The transposed matrix of 2; S323. The third attention layer includes eight attention heads, and the attention vector With the encoded feature vector Input together into the third attention layer to calculate the attention vector again D : ; in, D 1 to D 8 represents the normalized vectors of the eight attention heads in the third attention layer; , D i represents the normalized vector of the attention head of the third attention layer, 1≤i≤8; , , , Q 3. K 3. V 3 respectively represent the attention heads in the third attention layer Q vector, K vector, V vector, , , They represent the three initialization matrices of the attention head in the third attention layer respectively; Representation vector K 3 dimensions, express K The transposed matrix of 3; S324. Attention vector D With attention vector Perform residual connection and standardization operations to obtain the attention vector : ; Among them, Norm represents the standardization operation; Perform dimensionality reduction operation: ; After the normalization operation, the feature vector is obtained R : ; in and are the weight matrices of the 1D convolutional layer and the fully connected layer, and They are the biases of the 1D convolutional layer and the fully connected layer respectively; Relu is the activation function.
[0014] Furthermore, in the encoder, steps S311 to S314 are looped, and the input of each loop is the output of the previous loop, and the encoded feature vector is finally output. ; In the decoder, the loop is from step S321 to step S324, and the input of each loop is the output of the previous loop, and the final output word vector is .
[0015] Furthermore, before obtaining the tourist route through the probability model, the probability model is trained; during the training process, the word vector of the tourist route output by the probability model is calculated. Word vectors with real route word sequences The cross entropy loss between them is minimized using the gradient descent method, and the probability model parameters are updated through back propagation; The calculation method of the cross entropy loss is: ; in, n is the batch size of training samples, is the loss function, , .
[0016] Compared with the prior art, one or more of the above technical solutions can achieve at least one of the following beneficial effects: This method does not require any interaction with the real world. It only trains the model through historical tour route data (which can be obtained in large quantities from travel agencies, social platforms, etc.) to obtain a model with route recommendation capabilities. In terms of later maintenance, there is no need to make targeted adjustments based on changes in actual conditions. You only need to regularly update the tour route data to keep the model up to date. The present invention adopts a probability model, uses a large amount of itinerary routes in text form as training data, and automatically generates recommended routes according to the tourists' expected travel time by natural language processing methods; since itinerary routes in text form can be easily obtained from the tour records of travel agencies, the training data of the present invention is easy to obtain, and since the complex multi-factor recommendation problem is converted into a text processing problem, the model parameters and the amount of calculation are greatly reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0018] Figure 1 This is a probability model structure diagram of Example 1.
[0019] Figure 2 This is a flowchart of the probability model training of Example 1. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] Example 1 The present embodiment provides a method for automatically planning a travel route based on a probability model, comprising the following steps: S1. Based on the historical text data of real travel itineraries, a word sequence is generated based on the names of scenic spots, and a time sequence is generated based on the time period corresponding to the visited scenic spots.
[0022] In this embodiment, the names of scenic spots in the route are extracted in chronological order to form a word sequence. Y : ; Extract the time period corresponding to the scenic spot to form a time series T : ; in, token n is the name of the attraction, time n is the corresponding time period; Indicates the length of the sequence.
[0023] S2. Set query conditions; the query conditions include target time period information and route preference type information.
[0024] In this embodiment, the query condition .
[0025] in, , Respectively represent the start time and end time of the route; Indicates the preference type of the route. The preference type of the route is determined according to the attractions in the route. In the specific implementation process, the preference type can be calibrated by manual marking method.
[0026] S3. Build a probability model and obtain the travel route through the probability model.
[0027] like Figure 1 As shown, a probability model is constructed. The probability model includes an encoder and a decoder. The encoder includes a fusion embedding layer, a first attention layer, a first 1-dimensional convolution layer and a first fully connected layer connected in sequence; the decoder includes a second attention layer, a third attention layer, a second 1-dimensional convolution layer and a second fully connected layer connected in sequence; The query condition is embedded into the encoder through the fusion embedding layer, and the query vector is obtained after feature extraction, encoding, and full connection embedding; after the query vector passes through the first attention layer, the first 1D convolutional layer and the first fully connected layer, the encoded feature vector is output and input into the decoder through the third attention layer; the decoding feature vector is obtained based on the word sequence and time series, and the decoding feature vector is input into the decoder through the second attention layer; the decoder combines the word sequence, time series and encoded feature vector, calculates the conditional probability through the mutual attention mechanism, and obtains the word vector of the travel route.
[0028] In this embodiment, the query condition is embedded to obtain a query vector; the query vector is input into the encoder to obtain an encoded feature vector of the query condition; the word sequence generated in step S1 is word-embedded to obtain a word vector; the time series generated in step S1 is time-series embedded to obtain a time series vector; the obtained word vector, time series vector and encoded feature vector are input into the decoder to generate a word vector of the travel route.
[0029] The probability model constructed by this method pays more attention to information such as time arrangement and query conditions, improves the structure of the traditional Transformer model, and embeds the time series and query conditions separately and adds them to the model. Considering that the time series should correspond to the travel route (represented by the word sequence), it is merged with the word sequence and embedded in the decoder together. The query condition mainly serves as a priori in the reasoning process, so it is embedded in the encoder.
[0030] The fusion embedding layer of this embodiment uses a fully connected layer to embed the query conditions and obtain a query vector. First, initialize the fusion embedding layer weight matrix , the weight matrix The weights of the fused embedding layer can be trained along with the model using random initialization from a standard normal distribution N(0,1). q Input the fusion embedding layer to get the query vector corresponding to each word ,in, represents the weight matrix of the fused embedding layer, is the corresponding bias.
[0031] After the query vector passes through the first attention layer, the first 1D convolutional layer, and the first fully connected layer, the method of outputting the encoded feature vector specifically includes the following steps: S311. Query vector X The three initialization matrices of each attention head in the first attention layer are calculated to obtain the attention head in the first attention layer. Q vector, K vector, V Vector. The following takes the first attention layer as a multi-head attention layer with eight attention heads as an example.
[0032] For each attention head there are three initialization matrices , and , the query vector X Calculate three vectors with these three matrices respectively: , , ; (1) in, , and It is a learnable matrix, and the weights are updated along with the model; Q 1. K 1. V 1 represents the attention head in the first attention layer Q vector, K vector, V vector.
[0033] S312. Based on the data obtained in step S311 Q 1. K 1. V 1. Calculate the attention score for each attention head and normalize it to obtain the normalized vector.
[0034] Specifically, the attention score is calculated and normalized using formula (2): ; (2) in Z i represents the normalized vector of the first attention layer’s attention head; Representation vector The dimension of express The transposed matrix of .
[0035] S313. Concatenate the normalized vectors of each attention head of the first attention layer to obtain the attention vector Z.
[0036] After the multi-head attention mechanism, eight vectors are obtained. The attention vector is obtained by concatenating multiple vectors using formula (3): ; (3) Among them, Z1 to Z 8 respectively represent the normalized vectors obtained by the eight attention heads of the first attention layer through step S312.
[0037] S314. After performing residual connection and normalization operation on the attention vector Z and the original input D, a dimensionality reduction operation is performed, and then a normalization operation is performed to obtain the encoded feature vector.
[0038] Specifically, the attention vector Z is residually connected to the original input D using formula (4), and the input of the fully connected layer is obtained after normalization: ; (4) in, Represents a standardization operation. For a certain input matrix =[ ], calculate the mean of all elements in it , standard deviation , then the elements in the matrix are standardized and passed into the nonlinear activation function , where x1 to x H is the element in the matrix, H is the sequence number of the element, represents the sigmoid function, are two adaptive parameters that can be adjusted along with the model. The initial value .join in This is to preserve the nonlinear capability of the model.
[0039] This embodiment uses a 1D convolutional layer to reduce the dimension of the attention vector, specifically: ; (5) Among them, O represents the vector after dimensionality reduction operation, represents 1D convolution, represents the convolution kernel parameters, Indicates the corresponding bias.
[0040] The output and input of the fully connected layer in this embodiment are also residually connected, and the output also needs to be standardized, that is: ; (6) Among them, P represents the vector after the normalization operation, represents the weight matrix of the fully connected layer, Represents the corresponding bias, Relu represents the activation function .
[0041] Step S311 to step S314 is a calculation process of one cycle. In the subsequent cycles, the input of each cycle is no longer the initial code but the output of the previous cycle, that is: ;in, Represents the process shown in formula (1)-(6), and the final output is the encoded feature vector .
[0042] As a specific implementation method, this embodiment sets up a parallel text embedding layer and a time series embedding layer to embed the word sequence and the time series respectively, and obtain the word vector corresponding to the word sequence and the time series vector corresponding to the time series; the word vector and the time series vector are the same type of vectors, which are integrated into a decoding feature vector through a bitwise addition operation.
[0043] The text embedding layer of this embodiment uses a learnable vocabulary to embed the generated word unit sequence and generate a word vector. First, the learnable vocabulary is initialized, and the encoding value of each word unit in the vocabulary is randomly initialized, and the encoding value will be updated along with the network training.
[0044] The time series embedding layer of this embodiment uses a fully connected layer to embed the generated time series into words. First, initialize the weight matrix of the time series embedding layer. , the weight matrix Using random initialization following a standard normal distribution N(0,1), the weight matrix Can be trained together with the model. Input the time series embedding layer to get the time series vector corresponding to each word ;in, is the weight matrix of the temporal embedding layer, is the corresponding bias.
[0045] The decoder combines the word sequence, time series and encoded feature vector, calculates the conditional probability through the mutual attention mechanism, and the method for obtaining the word vector of the travel route includes the following steps: S321. Obtain word vectors based on word sequence The time series vector obtained based on the time series Add the corresponding elements in to get the vector E The second attention layer is a multi-head attention layer, and the following takes eight attention heads as an example.
[0046] Specifically, the word vector With time series vector Add corresponding elements .
[0047] S322. Multiply the vector E by the three initialization matrices of the attention head in the second attention layer to obtain Q vector, K vector, V vector, calculate the attention score of each attention head in the second attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads in the second attention layer to obtain an attention vector U ; The attention vector U With word vector Perform residual connection and normalization to obtain the attention vector .
[0048] Specifically, the vector The attention vector is obtained through the second multi-head attention layer ; in, , U 1 to U 8 represents the normalized vector of the eight attention heads in the second attention layer; , U i represents the normalized vector of the attention head of the second attention layer, 1≤i≤8; Q 2. K 2. V 2 respectively represent the attention heads in the second attention layer Q vector, K vector, V vector, Representation vector K Dimension 2, express K 2's transposed matrix.
[0049] S323. Attention vector , encoding feature vector Calculate the initialization matrix of the attention head in the third attention layer respectively to obtain the initialization matrix of the attention head in the third attention layer Q vector, K vector, V vector; calculate the attention score for each attention head of the third attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads of the third attention layer to obtain an attention vector D .
[0050] Specifically, the attention vector With the encoded feature vector Input the third attention layer together to calculate the attention vector again; get the attention vector ; in, D 1 to D 8 represents the normalized vectors of the eight attention heads in the third attention layer; , D i represents the normalized vector of the attention head of the third attention layer, 1≤i≤8; , , , Q 3.K 3. V 3 respectively represent the attention heads in the third attention layer Q vector, K vector, V vector, , , They represent the three initialization matrices of the attention head in the third attention layer respectively; Representation vector K 3 dimensions, express K 3 is the transposed matrix.
[0051] S324. Attention vector D With attention vector After residual connection and standardization, dimensionality reduction is performed, and then standardization is performed to obtain the feature vector R .
[0052] The second 1D convolutional layer and the second fully connected layer in the decoder are the same as those in the encoder, and the process is: ; ; in and are the weight matrices of the 1D convolutional layer and the fully connected layer, and They are the biases of the 1D convolutional layer and the fully connected layer respectively; Relu is the activation function .
[0053] In the decoder, steps S321 to S324 are looped, and the input of each loop is the output of the previous loop: , and finally output the word vector ; Wherein decoder represents the process from step S321 to step S324.
[0054] like Figure 2 As shown, the probability model provided by the present invention is a trained probability model. During the training process, the word vector output by the probability model is calculated. Compared with the real route word vector The cross entropy loss between them is minimized using the gradient descent method, and the probability model parameters are updated through back propagation; Among them, for all and Calculate the cross entropy loss: ; in, n is the batch size of training samples, is the loss function.
[0055] The method of this embodiment does not require inputting the actual route and time arrangement, and only requires inputting the query conditions to generate a travel route. First, only input the query conditions , the word vector obtained And the resulting time series vector are all replaced by zero vectors. The final output vector is After that, use the weight matrix of the learnable vocabulary obtained through training Will Mapping as text: ;in, for The inverse matrix of .
[0056] The method of this embodiment can dynamically adjust the itinerary to meet the preferences and travel time of tourists, and has the advantages of small model parameters and calculation amount, easy acquisition of training data, and convenient subsequent maintenance and updating.
[0057] Obviously, the above embodiments are merely examples for clearly explaining the technical solutions of the present invention, and are not intended to limit the implementation methods of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included in the protection of the claims of the present invention.
Claims
1. A method for automatically planning a tourist route based on a probability model, characterized in that: The following steps are involved: S1. Generate word sequence based on the name of scenic spot according to the historical text data of real travel itinerary, and generate time sequence based on the time period corresponding to the scenic spot; S2. Set query conditions, the query conditions including target time period information and route preference type information; S3. Build a probability model and obtain the travel route through the probability model; The probability model includes an encoder and a decoder; the encoder includes a fusion embedding layer, a first attention layer, a first 1-dimensional convolutional layer and a first fully connected layer connected in sequence; the decoder includes a second attention layer, a third attention layer, a second 1-dimensional convolutional layer and a second fully connected layer connected in sequence; The query condition is embedded into the encoder through a fusion embedding layer, and after feature extraction, encoding, and full connection embedding, a query vector is obtained; After the query vector passes through the first attention layer, the first 1D convolutional layer and the first fully connected layer, the encoded feature vector is output and input into the decoder through the third attention layer; a decoding feature vector is obtained based on the word sequence and the time series, and the decoding feature vector is input into the decoder through the second attention layer; the decoder combines the word sequence, the time series and the encoded feature vector, calculates the conditional probability through the mutual attention mechanism, and obtains the word vector of the travel route.
2. The method for automatically planning a tourist route based on a probability model according to claim 1, characterized in that: The method for obtaining a decoding feature vector based on a word sequence and a time series is as follows: a text embedding layer and a time series embedding layer are set in parallel to embed the word sequence and the time series respectively to obtain a word vector corresponding to the word sequence and a time series vector corresponding to the time series; the word vector and the time series vector are vectors of the same type and are integrated into a decoding feature vector through a bitwise addition operation.
3. The method for automatically planning a tourist route based on a probability model according to claim 2, characterized in that: The text embedding layer uses a learnable vocabulary to embed the generated word sequence; Initialize the learnable vocabulary, randomly initialize the encoding value of each word in the vocabulary, and the encoding value is updated along with the network training; Furthermore, the calculation formula of the time series vector is: ;in, represents a time series, represents the weight matrix of the temporal embedding layer. The weight matrix is randomly initialized using a standard normal distribution N(0,1). Indicates the corresponding bias.
4. The method for automatically planning a tourist route based on a probability model according to claim 1, characterized in that: The calculation formula of the query vector is: ; in, X represents the query vector, q Indicates the query condition. represents the weight matrix of the fused embedding layer. The weight matrix is randomly initialized using a standard normal distribution N(0,1). Indicates the corresponding bias.
5. The method for automatically planning a tourist route based on a probability model according to claim 1, characterized in that: The method of outputting a coded feature vector after the query vector passes through a first attention layer, a first 1-dimensional convolutional layer, and a first fully connected layer comprises the steps of: S311. Query vector X The three initialization matrices of each attention head in the first attention layer are calculated to obtain the attention head in the first attention layer. Q vector, K vector, V vector; S312. Based on the attention head in the first attention layer Q vector, K vector, V Vector, calculate the attention score for each attention head and normalize it to obtain the normalized vector; S313. Concatenate the normalized vectors of each attention head of the first attention layer to obtain an attention vector Z; S314. After performing residual connection and normalization operation on the attention vector Z and the original input, a dimensionality reduction operation is performed, and then a normalization operation is performed to obtain the encoded feature vector.
6. The method for automatically planning a tourist route based on a probability model according to claim 5, characterized in that: Steps S311 to S314 specifically include: S311. The first attention layer has eight attention heads, each with three initialization matrices. , and , the query vector X Calculated with the matrix respectively, , , ;(1) in, , and All are learnable matrices; Q 1. K 1. V 1 represents the attention head in the first attention layer Q vector, K vector, V vector; S312. Calculate the attention score and normalize it: ;(2) in Z i represents the normalized vector of the first attention layer’s attention head; Representation vector The dimension of express The transposed matrix of . S313. Concatenate the normalized vectors of each attention head in the first attention layer to obtain the attention vector Z ; ;(3) Among them, Z1 to Z 8 represent the normalized vectors obtained by the eight attention heads of the first attention layer through step S312 respectively; S314. Attention vector Z With the original input D Perform residual connection and standardize to get the attention vector , as the input of the first fully connected layer: ;(4) in, Indicates standardized operation; The first 1D convolutional layer focuses on the attention vector Perform dimensionality reduction operations, specifically: ;(5) Among them, O represents the vector after dimensionality reduction operation, represents 1D convolution, represents the convolution kernel parameters, represents the corresponding bias; The output of the first fully connected layer is residually connected to the input, and the output of the first fully connected layer is standardized: ;(6) Among them, P represents the vector after the normalization operation, represents the weight matrix of the first fully connected layer, Represents the corresponding bias, and Relu represents the activation function.
7. The method for automatically planning a tourist route based on a probability model according to claim 6, characterized in that: The decoder combines the word sequence, the time series and the encoded feature vector, calculates the conditional probability through the mutual attention mechanism, and the method for obtaining the word vector of the travel route includes the steps of: S321. Obtain word vectors based on word sequence The time series vector obtained based on the time series Add the corresponding elements in to get the vector E ; S322. Based on the vector E and the three initialization matrices of the attention head in the second attention layer, obtain the attention head in the second attention layer Q vector, K vector, V vector; calculate the attention score for each attention head in the second attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads in the second attention layer to obtain an attention vector U ; The attention vector U With word vector Perform residual connection and normalization to obtain the attention vector ; S323. Based on attention vector , encoding feature vector And the initialization matrix of the attention head in the third attention layer, get the initialization matrix of the attention head in the third attention layer Q vector, K vector, V vector; calculate the attention score for each attention head of the third attention layer and normalize it to obtain a normalized vector; concatenate the normalized vectors of all attention heads of the third attention layer to obtain an attention vector D ; S324. Attention vector D With the attention vector After residual connection and standardization, dimensionality reduction is performed, and then standardization is performed to obtain the feature vector R .
8. The method for automatically planning a tourist route based on a probability model according to claim 7, characterized in that: Steps S321 to S324 specifically include: S321. Obtain word vectors based on word sequence The time series vector obtained based on the time series Add the corresponding elements in to get the vector E : ; S322. The second attention layer includes eight attention heads, and the vector E The attention vector is obtained through the second multi-head attention layer ; in, , U 1 to U 8 represents the normalized vectors of the eight attention heads in the second attention layer; , U i represents the normalized vector of the attention head of the second attention layer, 1≤i≤8; Q 2. K 2. V 2 respectively represent the attention heads in the second attention layer Q vector, K vector, V vector, Representation vector K Dimension 2, express K The transposed matrix of 2; S323. The third attention layer includes eight attention heads, and the attention vector With the encoded feature vector Input together into the third attention layer to calculate the attention vector again D : ; in, D 1 to D 8 represents the normalized vectors of the eight attention heads in the third attention layer; , D i represents the normalized vector of the attention head of the third attention layer, 1≤i≤8; , , , Q 3. K 3. V 3 respectively represent the attention heads in the third attention layer Q vector, K vector, V vector, , , They represent the three initialization matrices of the attention head in the third attention layer respectively; Representation vector K 3 dimensions, express K The transposed matrix of 3; S324. Attention vector D With the attention vector Perform residual connection and standardization operations to obtain the attention vector : ; Among them, Norm represents the standardization operation; Perform dimensionality reduction operation: ; After the normalization operation, the feature vector is obtained R : ; in and are the weight matrices of the 1D convolutional layer and the fully connected layer, and They are the biases of the 1D convolutional layer and the fully connected layer respectively; Relu is the activation function.
9. The method for automatically planning a tourist route based on a probability model according to claim 6, characterized in that: In the encoder, steps S311 to S314 are looped, and the input of each loop is the output of the previous loop, and the encoded feature vector is finally output. ; In the decoder, the loop is from step S321 to step S324, and the input of each loop is the output of the previous loop, and the final output word vector is .
10. The method for automatically planning a tourist route based on a probability model according to any one of claims 2 to 9, characterized in that: Before obtaining the tourist route through the probability model, the probability model is trained; during the training process, the word vector of the tourist route output by the probability model is calculated Word vectors with real route word sequences The cross entropy loss between them is minimized using the gradient descent method, and the probability model parameters are updated through back propagation; The cross entropy loss is calculated as: ; in, n is the batch size of training samples, is the loss function, , .
