Training method of link generation model, link generation method and device
By keeping the encoder parameters unchanged in the road segment generation model and updating the generator and discriminator parameters, the overfitting problem caused by insufficient sample road segments is solved, and the effect of efficiently generating new road segments with multiple styles is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2023-05-22
- Publication Date
- 2026-05-19
AI Technical Summary
In existing technologies, the limited number of sample road segments makes it easy for road segment generation models to overfit, making it difficult to generate diverse new road segments and resulting in low road segment generation efficiency.
A road segment generation model training method is adopted. By keeping the network parameters of the road segment encoder unchanged, the network parameters of the road segment generator are updated. The network parameters of the road segment generator and the discriminator are updated alternately using reference road segment information and sample road segment information to generate adjacent road segment information.
It improves the efficiency of road segment generation, enabling the rapid generation of new road segments similar to sample road segments, reducing labor costs and intensity, and the generated road segments possess the style and quality of existing road segments.
Smart Images

Figure CN116957039B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a training method, a method for generating road segments, and an apparatus for generating road segments. Background Technology
[0002] With the continuous development of computer technology, the types and number of games are also increasing, and racing games, parkour games, and other genres have emerged. For example, in racing games, players can control virtual vehicles to run on different virtual roads. These virtual roads can be viewed as multiple segments connected end to end. Generally, the more diverse the types of virtual roads, the better the player's gaming experience.
[0003] In related technologies, a road segment generation model based on supervised learning is used to generate road segments. For example, existing virtual road segments are used as sample road segments. Variational Auto Encoder (VAE) technology is used to encode and fit the road segment information of the sample road segments. Then, based on the encoded road segment vectors, the road segment generation model is trained, and the trained road segment generation model is used to generate new road segments.
[0004] However, in the above methods, due to the limited number of sample road segments extracted from existing virtual roads, the road segment generation model trained will suffer from overfitting, making it difficult to generate multiple new road segments with different styles, resulting in low road segment generation efficiency. Summary of the Invention
[0005] This application provides a training method for a road segment generation model, a road segment generation method, and an apparatus, which can improve the efficiency of road segment generation. The technical solution is as follows:
[0006] On the one hand, a training method for a road segment generation model is provided, the method comprising:
[0007] The method obtains a road segment generation model and road segment information of multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator. The road segment encoder is used to encode the road segment information of the road segment to obtain the road segment vector of the road segment. The road segment generator is used to generate the road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment.
[0008] Based on the road segment information of multiple sample road segments, the road segment generator and the road segment encoder are trained sequentially;
[0009] During the training of the road segment generator, the network parameters of the road segment encoder are kept unchanged. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments, the network parameters of the road segment generator are updated.
[0010] During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the input first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment.
[0011] On the other hand, a road segment generation method is provided, the method comprising:
[0012] Obtain road segment information;
[0013] The road segment information of the road segment is encoded by the road segment encoder of the road segment generation model to obtain the road segment vector of the road segment. The road segment generation model is trained according to the training method of the road segment generation model provided in the embodiments of this application.
[0014] The road segment generator of the road segment generation model generates road segment information for the next road segment adjacent to the road segment based on the road segment vector of the road segment.
[0015] On the other hand, a training device for a road segment generation model is provided, the device comprising:
[0016] The acquisition module is used to acquire road segment information of a road segment generation model and multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator. The road segment encoder is used to encode the road segment information of the road segment to obtain the road segment vector of the road segment. The road segment generator is used to generate the road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment.
[0017] The training module is used to train the road segment generator and the road segment encoder sequentially based on the road segment information of multiple sample road segments;
[0018] During the training of the road segment generator, the network parameters of the road segment encoder are kept unchanged. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments, the network parameters of the road segment generator are updated.
[0019] During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the input first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment.
[0020] In some embodiments, the training module includes a first training unit, the first training unit being configured to:
[0021] The road segment generator generates road segment information corresponding to each reference vector based on multiple reference vectors. The reference vectors are obtained by sampling the reference distribution of the road segment vectors.
[0022] Based on the road segment information of multiple sample road segments and multiple reference road segments, the network parameters of the road segment generator and the network parameters of the first discriminator are alternately updated to obtain the updated road segment generator and the updated first discriminator. The first discriminator is used to determine whether a road segment is a sample road segment.
[0023] In some embodiments, the reference distribution of the road segment vector is a uniform distribution, and the reference vector is obtained by randomly sampling the uniform distribution.
[0024] In some embodiments, the first training unit is configured to:
[0025] In the i-th round of alternating updates, the loss value of the first discriminator is determined based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments. Based on the loss value of the first discriminator, the network parameters of the first discriminator are updated to obtain the updated first discriminator, where i is a positive integer.
[0026] The road segment information of multiple reference road segments is input into the updated first discriminator, and the discrimination result of each reference road segment is output. The discrimination result of the reference road segment indicates whether the reference road segment is the sample road segment.
[0027] Based on the discrimination results of each reference road segment, the loss value of the road segment generator is determined. Based on the loss value of the road segment generator, the network parameters of the road segment generator are updated to obtain the updated road segment generator.
[0028] In some embodiments, the training module includes a second training unit, the second training unit being configured to:
[0029] The road segment encoder encodes the road segment information of the first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment.
[0030] Based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, the network parameters of the road segment encoder and the network parameters of the second discriminator are alternately updated to obtain the updated road segment encoder and the updated second discriminator. The second discriminator is used to determine whether two adjacent road segments are two adjacent sample road segments.
[0031] In some embodiments, the second training unit is configured to:
[0032] In the qth round of alternating updates, the loss value of the second discriminator is determined based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. Based on the loss value of the second discriminator, the network parameters of the second discriminator are updated to obtain the updated second discriminator, where q is a positive integer.
[0033] The road segment information of the first road segment and the road segment information of the second road segment are input into the updated second discriminator, and the discrimination results of the first road segment and the second road segment are output. The discrimination results of the first road segment and the second road segment indicate whether the first road segment and the second road segment are two adjacent sample road segments.
[0034] Based on the road segment information of the second road segment and the discrimination results of the first road segment and the second road segment, the loss value of the road segment encoder is determined. Based on the loss value of the road segment encoder, the network parameters of the road segment encoder are updated to obtain the updated road segment encoder.
[0035] In some embodiments, the training module is used to encode the desired road segment information and the road segment information of the first road segment through the road segment encoder to obtain the road segment vector of the first road segment, wherein the desired road segment information indicates the road segment information of the second road segment expected to be generated by the road segment generator.
[0036] In some embodiments, the training module is configured to:
[0037] The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, the road segment information of the second road segment, and the difference between the road segment information of the second road segment and the expected road segment information.
[0038] In some embodiments, the road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters;
[0039] The first generator is used to generate the road segment type of the next road segment adjacent to the road segment based on the road segment vector of the road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the road segment and the road segment type of the next road segment.
[0040] On the other hand, a road segment generation device is provided, the device comprising:
[0041] The acquisition module is used to acquire road segment information.
[0042] The encoding module is used to encode the road segment information of the road segment through the road segment encoder of the road segment generation model to obtain the road segment vector of the road segment, wherein the road segment generation model is trained according to the training method of the road segment generation model according to any one of claims 1 to 9;
[0043] The generation module is used to generate a road segment generator based on the road segment vector of the road segment, and generate road segment information of the next road segment adjacent to the road segment.
[0044] In some embodiments, the acquisition module is further configured to:
[0045] Obtain desired road segment information, wherein the desired road segment information indicates the road segment information of the next road segment expected to be generated by the road segment generator;
[0046] The encoding module is used for:
[0047] The road segment encoder encodes the desired road segment information and the road segment information of the road segment to obtain the road segment vector.
[0048] In some embodiments, the road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters;
[0049] The first generator is used to generate the road segment type of the next road segment based on the road segment vector of the previous road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the previous road segment and the road segment type of the next road segment.
[0050] In some embodiments, the apparatus further includes:
[0051] The extraction module is used to extract the road segment type of the next road segment from the road segment information of the next road segment; and to extract the road segment parameters of the next road segment from the road segment information of the next road segment.
[0052] The road segment generation module is used to generate the next road segment based on the road segment type and the road segment parameters of the next road segment.
[0053] On the other hand, a computer device is provided, which includes a processor and a memory for storing at least one computer program, which is loaded and executed by the processor to implement the training method of the road segment generation model in the embodiments of this application, or to implement the road segment generation method in the embodiments of this application.
[0054] On the other hand, a computer-readable storage medium is provided, which stores at least one computer program, which is loaded and executed by a processor to implement the training method of the road segment generation model in the embodiments of this application, or to implement the road segment generation method in the embodiments of this application.
[0055] On the other hand, a computer program product is provided, comprising at least one computer program stored in a computer-readable storage medium. A processor of a computer device reads the at least one computer program from the computer-readable storage medium and executes the at least one computer program, causing the computer device to perform either the training method for the road segment generation model in the embodiments of this application, or the road segment generation method in the embodiments of this application.
[0056] This application discloses a road segment generation model comprising a road segment encoder and a road segment generator. During training, the network parameters of the road segment encoder are first fixed, and the network parameters of the road segment generator are updated. Then, the network parameters of the road segment generator are fixed, and the network parameters of the road segment encoder are updated. Since both the road segment generator and the road segment encoder can generate large amounts of data, the entire training process is independent of the number of sample road segments, thus eliminating concerns about overfitting due to insufficient sample road segments. The trained road segment generation model can quickly generate new road segments similar to the sample road segments, improving road segment generation efficiency. Furthermore, the road segment generation model provided in this application can generate a large number of road segments in a short time, imbuing them with the style and quality of existing road segments, thereby reducing the human resource cost and labor intensity of road segment generation. Attached Figure Description
[0057] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0058] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application;
[0059] Figure 2 This is a schematic diagram of the display interface of a track editor provided in an embodiment of this application;
[0060] Figure 3 This is a schematic diagram of the display interface of another track editor provided in an embodiment of this application;
[0061] Figure 4 This is a flowchart of a training method for a road segment generation model provided in an embodiment of this application;
[0062] Figure 5 This is a schematic diagram of a road segment type provided in an embodiment of this application;
[0063] Figure 6 This is a flowchart of another training method for a road segment generation model provided in an embodiment of this application;
[0064] Figure 7 This is a schematic diagram of a training method for a road segment generation model provided in an embodiment of this application;
[0065] Figure 8 This is a schematic diagram of another training method for a road segment generation model provided in an embodiment of this application;
[0066] Figure 9This is a flowchart of a road segment generation method provided in an embodiment of this application;
[0067] Figure 10 This is a schematic diagram of a road segment generation method provided in an embodiment of this application;
[0068] Figure 11 This is a schematic diagram of the structure of a training device for a road segment generation model provided in an embodiment of this application;
[0069] Figure 12 This is a schematic diagram of the structure of a road segment generation device provided in an embodiment of this application;
[0070] Figure 13 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;
[0071] Figure 14 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0073] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0074] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have essentially the same function. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms.
[0075] These terms are simply used to distinguish one element from another. For example, without departing from the scope of various examples, a first generator can be called a second generator, and similarly, a second generator can be called a first generator. Both a first generator and a second generator can be generators, and in some cases, they can be separate and distinct generators.
[0076] "At least one" refers to one or more generators. For example, at least one generator can be one generator, two generators, three generators, or any integer number of generators greater than or equal to one. "Multiple" refers to two or more generators. For example, multiple generators can be two generators, three generators, or any integer number of generators greater than or equal to two.
[0077] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, road segment information involved in this application was obtained with full authorization.
[0078] The key technologies involved in this application are described below.
[0079] Artificial intelligence (AI) is the theory, methods, technology, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.
[0080] Artificial intelligence (AI) is a comprehensive discipline encompassing a wide range of fields, including both hardware and software technologies. Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interactive systems, and mechatronics. AI software technologies primarily include computer vision, speech processing, natural language processing, and machine learning / deep learning.
[0081] Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning.
[0082] The implementation environment of this application is described below.
[0083] Figure 1 This is a schematic diagram of an implementation environment provided in an embodiment of this application. For example... Figure 1 As shown, the implementation environment includes a terminal 101 and a server 102. The terminal 101 and server 102 are directly or indirectly connected via a wired or wireless network, which is not limited herein. It should be noted that the training method for the road segment generation model provided in this application can be executed by the terminal device 101, by the server 102, or by both the terminal device 101 and the server 102. This application is not limited to these methods (the road segment generation method provided in this application is similar and will not be described further).
[0084] Terminal 101 includes, but is not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. Indicatively, terminal 101 can install and run an application that provides road segment generation functionality and can call the road segment generation model provided in this application to generate new road segments. For example, the application could be an animation-making application for designing virtual roads, etc., and is not limited thereto. In some embodiments, during the training process of the road segment generation model, terminal 101 can provide server 102 with information required for the training method of the road segment generation model, such as training parameters, sample road segments, and the initial AI model.
[0085] In some embodiments, terminal 101 generally refers to one of a plurality of terminals; this embodiment uses terminal 101 as an example only. Those skilled in the art will understand that the number of terminals 101 can be greater. For example, there may be dozens or hundreds, or even more, terminals 101, in which case the implementation environment may also include other terminals. This application does not limit the number of terminals or the type of device.
[0086] Server 102 is an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. The number of servers 102 can be more or less, and this application embodiment does not limit this. Of course, server 102 may also include other functional servers to provide more comprehensive and diversified services. In some embodiments, server 102 is used to execute the road segment generation model training method provided in this application embodiment, illustratively, training the road segment generation model based on information provided by terminal 101.
[0087] In some embodiments, the wired or wireless networks described above use standard communication technologies and / or protocols. The network is typically the Internet, but can be any network, including but not limited to Local Area Networks (LANs), Metropolitan Area Networks (MANs), Wide Area Networks (WANs), mobile, wired or wireless networks, private networks, or any combination of virtual private networks. In some embodiments, technologies and / or formats including Hyper Text Markup Language (HTML), Extensible Markup Language (XML), etc., are used to represent data exchanged over the network. Furthermore, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), and Internet Protocol Security (IPsec) can be used to encrypt all or some links. In other embodiments, custom and / or dedicated data communication technologies can be used to replace or supplement the aforementioned data communication technologies.
[0088] The application scenarios of this application are described below.
[0089] This application provides a road segment generation model that can be applied to scenarios involving the generation of new road segments from virtual roads, including but not limited to animation production, cloud technology, artificial intelligence, intelligent transportation, assisted driving, and vehicle simulation driving. Illustratively, the road segment generation model provided in this application is used to automatically generate multiple new road segments of different styles, thereby improving road segment generation efficiency. Taking the animation production scenario of a racing game as an example, since the richer the road segment styles of the virtual roads, the better the player's gaming experience, automatically generating multiple new road segments of different styles through the road segment generation model and quickly assembling these new road segments into a track can effectively improve road segment generation efficiency. Taking the vehicle simulation driving scenario as an example, by designing virtual roads with rich road segment styles, the driving environment of the vehicle can be fully simulated. Therefore, automatically generating multiple new road segments of different styles through the road segment generation model and quickly assembling these new road segments into the virtual road driven by the vehicle model can effectively improve road segment generation efficiency.
[0090] The following example, using the animation production scenario of a racing game, further illustrates the application scenarios of this application. In racing games, players can control virtual vehicles to run on different virtual roads. These virtual roads can be viewed as multiple road segments connected end to end. Generally, the more diverse the road segment styles, the better the player's gaming experience.
[0091] When designing racing games, a track editor can be used to design new tracks. A track is essentially a 3D model of a virtual road (in the following examples, the virtual road will be referred to as a track, and will not be elaborated further). A track editor is a tool for editing tracks (for example, an editor based on the Unity game engine). It runs from a terminal and displays the track editor's interface, while a server provides background services for the track editor. Illustratively, a track editor typically has functions such as creating new track segments, adding gates to track segments, connecting track segments, recommending tracks, and exporting tracks, etc. The specific implementation methods of these functions will be described below and will not be elaborated upon here.
[0092] A race track typically consists of multiple segments, which can be viewed as a series of segments connected end-to-end. You can design a segment using the track editor and use that segment as the track itself. In this case, the track comprises one segment, which is both the first and last segment of the track. Alternatively, you can design a segment using the track editor and attach it to any existing segment to create a new track. In other words, the new track is formed by combining the original track with the newly designed segment.
[0093] When designing road segments using the track editor, the track editor's "Create New Road Segment" function can be used to create a new road segment file. The road segment file includes configuration items for configuring the road segment type. Users can input the desired road segment type in these configuration items, or, depending on the selection of the configuration item, at least one candidate road segment type can be displayed. By selecting one of the candidate road segment types, the selected road segment type is adopted as the desired road segment type. Either of these methods allows for the design of the road segment type based on the configuration items for configuring the road segment type. Illustratively, road segment types may include, for example, straight sections, curves, bends, circles, etc., but this application does not limit this.
[0094] In addition, each road segment type corresponds to at least one road segment parameter. For example, if the road segment type is a straight road, the road segment parameters corresponding to a straight road usually include: road segment length, road segment width, road segment height, road segment inclination angle, etc., and this application is not limited to these; if the road segment type is a curve, the road segment parameters corresponding to a curve usually include: road segment arc length, road segment angle, etc., and this application is not limited to these.
[0095] The road segment file also includes configuration items for configuring various road segment parameters corresponding to different road segment types. For any configuration item used to configure road segment parameters, you can enter the desired road segment parameters, or, depending on the selection of the configuration item, display the initial parameters. By adjusting (i.e., decreasing or increasing) the initial parameters, the adjusted parameters will be used as the desired road segment parameters. Either of these two methods allows you to design corresponding road segment parameters based on the configuration items for the road segment parameters.
[0096] It should be noted that the above instructions for configuring the items are merely illustrative. In actual applications, other operations may be performed, which will not be elaborated here.
[0097] A track segment designed using the track editor has two gates by default: an entry gate and an exit gate. Walls are not generated at the edges of gates, but are automatically generated at the edges where there are no gates. Normally, walls prevent virtual vehicles, characters, and other virtual objects from passing through. Therefore, by generating walls at the edges where there are no gates but not at the edges of gates, virtual objects can be restricted from moving on the track while still being able to enter and exit through gates. You can use the track editor's feature to add gates to a track segment, designing new entry and / or exit gates. For each designed entry or exit gate, initial parameters can be used as the desired parameters, or these parameters can be manually configured, such as the width and height of the entry gate. Furthermore, walls are not generated at the edges of newly designed gates. Therefore, a track segment corresponds to at least two gates, including an entry gate and an exit gate, with at least one entry gate and at least one exit gate.
[0098] The track editor's segment connection function allows you to attach a newly designed segment to any existing track segment, creating a new track. For ease of description, let's denote any existing track segment as segment A and the newly designed segment as segment B. Based on the segment connection function, a connection is established between the exit gate of segment A and the entrance gate of segment B. In this case, the position of segment A can remain unchanged, while the position and orientation of segment B will automatically adjust so that the entrance gate of segment B aligns with the exit gate of segment A, and the entrance gate of segment B is attached to the exit gate of segment A. At this point, the relative positions of segment B and segment A remain unchanged.
[0099] As mentioned above, each road segment corresponds to at least one entrance gate and at least one exit gate, and the entrance gate of a newly designed road segment can be attached to the exit gate of any other road segment on the track. It can be understood that the same entrance gate can be attached to at least two exit gates, and different entrance gates can also be attached to at least two exit gates, with any two exit gates being either the same or different, and any two entrance gates being either the same or different. For example, the exit gate of road segment A is attached to the entrance gate of road segment B, and the exit gate of road segment B is attached to the entrance gate of road segment C, forming a road segment "Road Segment A - Road Segment B - Road Segment C," which can be called the main road. Based on this, a new exit gate can be created for road segment A, and a new entrance gate can be created for road segment C, and these two exit gates can be attached together, forming a road segment "Road Segment A - Road Segment C," which can be called a shortcut.
[0100] Additionally, the track editor's recommended route segment function can be used to invoke the route segment generation model and automatically generate new routes. Planners can then edit the generated routes or retract them, invoking the route segment generation model to generate a new recommendation. It should be understood that because the route segment generation model involves a probabilistic sampling process, the output under the same input is not fixed and will have a certain degree of randomness; therefore, the re-recommendation will differ from the previous recommendation. Thus, without manual intervention or expending design inspiration, repeatedly using the "recommended route segment" function several times can quickly generate a very long track. This not only improves the efficiency of new track design but also, as a content creation aid, alleviates the mental strain on content creators regarding design inspiration.
[0101] Indicatively, for reference Figure 2 , Figure 2 This is a schematic diagram of the display interface of a track editor provided in an embodiment of this application. For example... Figure 2 As shown, the track editor's display interface includes a "Recommended Segment" control, which is used to generate new segments. When the user selects the "Recommended Segment" control, the track editor can call the segment generation model to automatically generate a new segment. For example, if the last segment of the current track is denoted as D, the next segment E adjacent to segment D will be automatically generated by calling the segment generation model. In addition, the display interface also shows "Create Segment," "Add Door," "Establish Connection," and "Export Track" controls. The "Create Segment" control is used to create new segments, the "Add Door" control is used to add doors to segments, the "Establish Connection" control is used to connect segments, and the "Export Track" control is used to export the track. The functions of the other controls on the display interface are not limited in this embodiment.
[0102] By utilizing the track editor's functions for creating new road segments, adding gates to road segments, connecting road segments, and recommending road segments, multiple road segments can be designed and connected end-to-end to form a track. This track may include a main road or a main road and a shortcut. In this case, the designed track can be exported using the track editor's track export function to obtain a track file. This application does not limit the format of the track file; for example, the track file may be in FBX format (a file format inherent to animation software). (Illustratively, see reference...) Figure 3 , Figure 3 This is a schematic diagram of the display interface of another track editor provided in this application embodiment, which shows a track formed by connecting multiple road segments end to end.
[0103] It should be noted that the track can be further processed based on the track file. For example, animation rendering software can be used to fine-tune and refine the shape of the virtual road, apply textures, and perform other post-processing to ultimately obtain a finished track that can be deployed in game levels.
[0104] Based on the above description of the application scenarios of this application, the following describes the training method of the road segment generation model provided by this application and the method of generating road segments using the trained road segment generation model through several method implementation examples.
[0105] Figure 4 This is a flowchart illustrating a training method for a road segment generation model provided in an embodiment of this application. Figure 4 As shown, the method is performed by a computer device, which can provide the above-described... Figure 1 The terminal or server shown is schematically illustrated, and the method includes the following steps 401 and 402.
[0106] 401. The computer equipment acquires road segment generation model and road segment information of multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator.
[0107] In this embodiment of the application, for any road segment, the road segment generation model can predict the road segment information of the next road segment adjacent to the road segment based on the road segment information of the road segment, thereby outputting the road segment information of the next road segment, so that the style of the next road segment is similar to that of the road segment, or in other words, it has a similar style and quality to that road segment.
[0108] The road segment generation model consists of two parts: a road segment encoder and a road segment generator. The road segment encoder encodes the road segment information to obtain the road segment vector. The road segment generator generates the road segment information of the next adjacent road segment based on the road segment vector. For example, both the road segment encoder and the road segment generator are three-layer fully connected neural networks, but this application is not limited to this.
[0109] Multiple sample road segments are road segments determined from sample virtual roads. These sample virtual roads can be manually designed virtual roads or virtual roads generated using a road segment generation model within a historical time period. This application does not limit the source of the sample virtual roads. Illustratively, a computer device acquires a virtual road file containing road segment information for each sample road segment within the sample virtual road, thereby enabling the computer device to extract road segment information for multiple sample road segments from this virtual road file.
[0110] In some embodiments, the road segment information of the sample road segment includes at least one of the road segment type and road segment parameters. The road segment type and road segment parameters are described below.
[0111] Road segment types include straight roads, curves, turns, circles, rectangular circles, etc., and this application is not limited to these. Illustratively, road segment types can be represented by a type vector t, which can also be understood as vectorizing the information of road segment type. For example, the type vector t is a five-dimensional one-hot encoded vector. If the type vector t = (1, 0, 0, 0, 0), the road segment type is a straight road; if t = (0, 1, 0, 0, 0), the road segment type is a curve; if t = (0, 0, 1, 0, 0), the road segment type is a turn; if t = (0, 0, 0, 1, 0), the road segment type is a circle; if t = (0, 0, 0, 0, 1), the road segment type is a rectangular circle. (Reference) Figure 5 , Figure 5 This is a schematic diagram of a road segment type provided in an embodiment of this application. For example... Figure 5 As shown, from left to right, the road segments are straight, curved, bend, circular, and rectangular. It should be understood that the above description of road segment types does not constitute a limitation of this application. In some embodiments, road segment types also include other forms, such as curved straight roads, curved curved roads, etc. The representation of road segment types can also be done in other ways, such as by using a 9-dimensional one-hot encoded vector, etc. This application is not limited to these.
[0112] Road segment parameters refer to the road segment parameters corresponding to different road segment types. For example, if the road segment type is a straight road, the road segment parameters corresponding to a straight road typically include: road segment length, road segment width, road segment height, road segment inclination angle, etc., and this application is not limited to these; if the road segment type is a curve, the road segment parameters corresponding to a curve typically include: road segment arc length, road segment angle, etc., and this application is not limited to these. Schematic, road segment parameters can be represented by a parameter vector p, which can also be understood as vectorizing the information of road segment parameters. For example, the parameter vector p is a six-dimensional one-hot encoded vector, and the dimension value of each dimension corresponds to different road segment parameters, as shown in Table 1 below.
[0113] Table 1
[0114]
[0115] In Table 1 above, the first row represents the road segment type, including straight roads, curves, bends, loops, and rectangular loops. The first column represents each dimension of the parameter vector p. Taking a straight road as an example, its parameter vector p is a six-dimensional encoding vector. The road segment parameter corresponding to the first dimension is "road length", the road segment parameter corresponding to the second dimension is "entrance width", the road segment parameter corresponding to the third dimension is "0" (i.e., the turning angle is 0), the road segment parameter corresponding to the fourth dimension is "height difference from entrance to exit", the road segment parameter corresponding to the fifth dimension is "left curve difference", and the road segment parameter corresponding to the sixth dimension is "right curve difference". The other road segment types are similar, so they will not be described again. It should be understood that the above description of the road segment parameters does not constitute a limitation of this application. In some embodiments, the road segment parameters also include other contents, and this application is not limited thereto.
[0116] Furthermore, the above description of the road segment information for the sample road segments also applies to the road segment information of any road segment involved in this application, and will not be repeated hereafter.
[0117] In some embodiments, if the road segment information includes road segment type and road segment parameters, the road segment generator includes a first generator and a second generator. The first generator is used to generate the road segment type of the next road segment adjacent to the current road segment based on the road segment vector of the current road segment. This first generator is also called a road segment type generator (G-type). The second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the current road segment and the road segment type of the next road segment. This second generator is also called a road segment parameter generator (G-param).
[0118] The following example, using a road segment generator comprising a first generator and a second generator, illustrates the specific form of the road segment generation model.
[0119] As can be seen from the foregoing introduction, the road segment encoder of the road segment generation model can be a three-layer fully connected neural network. Schematic, the road segment encoder is implemented by the following formula (1):
[0120]
[0121] In the above formula (1), z is the output result of the road segment encoder, that is, the road segment vector, which is a 16-dimensional latent space vector; t is the type vector of the road segment (see the above introduction); p is the parameter vector of the road segment (see the above introduction); matrix W0 and bias vector b0 are the network parameters of the first fully connected neural network; matrix W1 and bias vector b1 are the network parameters of the second fully connected neural network; matrix W2 and bias vector b2 are the network parameters of the third fully connected neural network; relu and tanh are both activation functions; The Kronecker product is used to fully expand two vectors. For example, referring to the following formula (2), the Kronecker product of a two-dimensional vector [m1, m2] and a three-dimensional vector [n1, n2, n3] will become six-dimensional:
[0122]
[0123] As described above, if the type vector t is, for example, a 5-dimensional vector, and the parameter vector p is, for example, a 6-dimensional vector, then... A 30-dimensional vector can be obtained. That is, it is the input to the first fully connected neural network layer in the road segment encoder.
[0124] The road segment generator includes a first generator and a second generator. The specific forms of these two generators will be introduced below.
[0125] The first generator, also known as the road segment type generator (G-type), can be a three-layer fully connected neural network. Schematic, the first generator is implemented using the following formula (3):
[0126] t′=softmax(W5×relu(W4×relu(W3×[z]+b3)+b4)+b5) (3)
[0127] In the above formula (3), t′ is the output of the first generator, i.e., the road segment type of the next road segment; z is the output of the road segment encoder, i.e., the road segment vector; matrix W3 and bias vector b3 are the network parameters of the first fully connected neural network; matrix W4 and bias vector b4 are the network parameters of the second fully connected neural network; matrix W5 and bias vector b5 are the network parameters of the third fully connected neural network; ReLU and softmax are both activation functions.
[0128] The second generator, also known as the road segment parameter generator (G-param), can be a three-layer fully connected neural network. Schematic, the second generator is implemented using the following formula (4):
[0129]
[0130] In the above formula (4), p′ is the output result of the second generator, that is, the road segment parameter of the next road segment; therefore, it will not be elaborated further; t′ is the output result of the first generator, that is, the road segment type of the next road segment; z is the output result of the road segment encoder; That is, it is the input of the first fully connected neural network in the second generator; matrix W6 and bias vector b6 are the network parameters of the first fully connected neural network; matrix W7 and bias vector b7 are the network parameters of the second fully connected neural network; matrix W8 and bias vector b8 are the network parameters of the third fully connected neural network; ReLU and softmax are both activation functions.
[0131] The specific form of the road segment generation model provided in this application is introduced through the above formulas (1) to (4). It should be understood that the above are only illustrative examples and do not constitute a limitation on this application.
[0132] 402. The computer equipment trains the road segment generator and road segment encoder sequentially based on road segment information from multiple sample road segments.
[0133] In this embodiment, training the road segment generator and the road segment encoder sequentially means first training the road segment generator to obtain a trained road segment generator, and then using the trained road segment generator to train the road segment encoder to obtain a trained road segment encoder. The combination of the trained road segment encoder and the trained road segment generator yields the trained road segment generation model. In other words, this application provides a two-stage training method for training the road segment generation model: first training the road segment generator, and then training the road segment encoder.
[0134] In the training of the road segment generator, the network parameters of the road segment encoder are kept constant. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and multiple reference road segments, the network parameters of the road segment generator are updated. This method of training the road segment generator allows it to learn the road segment information of sample road segments. Therefore, when any road segment vector is input into the road segment generator, it can generate road segment information similar to that of the sample road segments. The specific implementation of this training process will be described in subsequent embodiments and will not be repeated here.
[0135] During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the first input road segment to obtain the road segment vector of the first road segment. Based on the road segment vector of the first road segment, the road segment generator generates the road segment information of the second road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment. By training the road segment encoder in this way, the road segment encoder can learn the relationship between two adjacent sample road segments, thereby encoding the road segment information more accurately and obtaining the road segment vector. Thus, inputting the road segment vector into the trained road segment generator can improve the quality of the road segment information generated by the road segment generator. The specific implementation method of this process will be described in subsequent embodiments and will not be repeated here.
[0136] Of course, the computer device can also repeat the above two-stage training method, that is, continue to keep the network parameters of the updated road segment encoder unchanged, and retrain the updated road segment generator, and so on. This application is not limited to this.
[0137] It should be noted that in steps 401 and 402 above, the input to the road segment generation model is the road segment information of any road segment. In other embodiments, the input to the road segment generation model also includes desired road segment information, which indicates the road segment information of the next road segment expected to be generated by the road segment generator. That is, the road segment encoder is used to encode the road segment information and the desired road segment information to obtain the road segment vector.
[0138] Schematic illustration: The desired road segment information can be represented by a target vector g. For example, the target vector g is a two-dimensional coded vector, where the dimension value of each dimension corresponds to the desired length and turning angle of the next road segment. The target vector g can be manually designed and generated, or it can be randomly generated by a computer device; this application is not limited to this. It should be noted that this is an illustrative example of desired road segment information and does not constitute a limitation of this application. In other embodiments, the desired road segment information can also be a multi-dimensional vector, or correspond to more information. For example, the desired road segment information can be a three-dimensional coded vector, where the dimension value of each dimension corresponds to the desired length, turning angle, and entrance width of the next road segment, etc.
[0139] Based on this, the road segment encoder can be implemented using the following formula (5):
[0140]
[0141] The parameters in formula (5) above are the same as those in formula (1) above, and the target vector g represents the desired road segment vector. This is the input to the first fully connected neural network layer in the road segment encoder. By also using the desired road segment information as input to the road segment generation model, the accuracy of the output results of the road segment generation model can be improved.
[0142] In summary, the training method for the road segment generation model provided in this application involves a road segment generation model including a road segment encoder and a road segment generator. During training, the network parameters of the road segment encoder are first fixed, and the network parameters of the road segment generator are updated. Then, the network parameters of the road segment generator are fixed, and the network parameters of the road segment encoder are updated. Since both the road segment generator and the road segment encoder can generate a large amount of data, the entire training process does not depend on the number of sample road segments. Therefore, there is no need to worry about model overfitting caused by insufficient sample road segments. The trained road segment generation model can quickly generate new road segments similar to the sample road segments, improving road segment generation efficiency.
[0143] Through the above Figure 4 The illustrated embodiment briefly describes the training method for the road segment generation model provided in this application. The following refers to... Figure 6 This paper provides a detailed introduction to the training method of the road segment generation model provided in this application.
[0144] Figure 6 This is a flowchart illustrating another method for training a road segment generation model provided in an embodiment of this application. For example... Figure 6 As shown, the method is performed by a computer device, which can provide the above-described... Figure 1 The terminal or server shown is schematically illustrated, and the method includes the following steps 601 to 605.
[0145] 601. The computer equipment acquires road segment generation model and road segment information of multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator.
[0146] This step is the same as step 401 above, so it will not be repeated here.
[0147] After acquiring the road segment generation model and road segment information from multiple sample road segments, the computer device performs the first stage of training on the road segment generation model through steps 602 and 603, which involves updating the network parameters of the road segment generator. Then, through steps 604 and 605, the road segment generation model performs the second stage of training, which involves updating the network parameters of the road segment encoder, ultimately obtaining the trained road segment generation model. This training process will be described in detail below.
[0148] 602. The computer equipment generates road segment information corresponding to each reference road segment based on multiple reference vectors through a road segment generator. The reference vector is obtained by sampling the reference distribution of the road segment vector.
[0149] The reference vector is an encoded latent variable obtained by sampling from the reference distribution of road segment vectors; that is, the reference vector can be understood as a pseudo-vector of the road segment vectors. In some embodiments, the reference distribution of the road segment vectors is a uniform distribution, and the reference vector is obtained by randomly sampling from the uniform distribution. For example, a uniform distribution refers to a uniform distribution between -1 and 1, and the reference vector is a 16-dimensional vector, with each dimension value randomly sampled from the uniform distribution between -1 and 1. It should be noted that since the reference vector is obtained by random sampling, the number of reference vectors can be massive, thus enabling the road segment generator to generate a massive amount of road segment information, thereby avoiding over-reliance on the number of sample road segments during training.
[0150] Taking any reference vector as an example, the computer device inputs the reference vector into the road segment generator, which processes the reference vector to obtain the road segment information corresponding to the reference vector. Schematic, the process of the road segment generator processing the reference vector is shown in formulas (3) and (4) above, and will not be repeated here.
[0151] 603. The computer device updates the network parameters of the road segment generator and the network parameters of the first discriminator alternately based on the road segment information of multiple sample road segments and multiple reference road segments, so as to obtain the updated road segment generator and the updated first discriminator.
[0152] The first discriminator is used to determine whether a road segment is a sample road segment. That is, given the road segment information of any given road segment, the first discriminator outputs a judgment result indicating whether the road segment is a sample road segment. In this step, the network parameters of the road segment generator and the first discriminator are updated alternately, employing a generative adversarial algorithm. By repeatedly updating the first discriminator and the road segment generator alternately, they upgrade each other through adversarial training, thus completing the training. It should be understood that the first discriminator can be deleted after training, and the trained road segment generator can be used as part of the road segment generation model to generate road segments.
[0153] Schematic, the first discriminator is also called the road segment shape discriminator (D-shape, abbreviated as Ds), which can be a three-layer fully connected neural network. For example, taking a road segment generator that includes a first generator and a second generator as an example, the first discriminator is implemented by the following formula (6):
[0154]
[0155] In the above formula (6), t′ is the output of the first generator; p′ is the output of the second generator; That is, it is the input of the first fully connected neural network layer in the first discriminator; matrix W9 and bias vector b9 are the network parameters of the first fully connected neural network layer; matrix W 10 and bias vector b 10 The network parameters for the second fully connected neural network layer; matrix W 11 and bias vector b 11 These are the network parameters for the third fully connected neural network layer; ReLU and sigmoid are both activation functions.
[0156] It should be understood that since the first discriminator can determine whether a road segment is a sample road segment, if the road segment information of the reference road segment generated by the road segment generator is input into the first discriminator, the first discriminator will output that it is not a sample road segment, for example, by outputting a value of "-1"; if the road segment information of the sample road segment is input into the first discriminator, the first discriminator will output that it is a sample road segment, for example, by outputting a value of "+1". For the road segment generator, its training goal is to make the road segment information generated by the road segment generator close to the road segment information of the sample road segment, or in other words, to have similar quality and style as the sample road segment. Correspondingly, for the first discriminator, its training goal is to make the road segment information generated by the road segment generator obtain a higher output in the first discriminator, for example, an output value close to "+1". In other words, its training goal is to make the first discriminator determine the road segment information generated by the road segment generator as a sample road segment. In this way, the road segment generator can generate "deceptively realistic" road segment information, thereby improving the accuracy of the model's output results. By employing this generative adversarial algorithm, the first discriminator and the road segment generator are updated alternately multiple times, allowing them to upgrade through adversarial training, thus completing the training and obtaining the updated first discriminator and the updated road segment generator.
[0157] The following describes the process of the computer device alternately updating the network parameters of the road segment generator and the network parameters of the first discriminator, taking any round of alternating update as an example (hereinafter referred to as the i-th round of alternating update, where i is a positive integer). The process includes steps A1 to A3 below.
[0158] Step A1: Based on the road segment information of multiple sample road segments and multiple reference road segments, determine the loss value of the first discriminator. Based on the loss value of the first discriminator, update the network parameters of the first discriminator to obtain the updated first discriminator.
[0159] The computer device inputs road segment information from multiple sample road segments into the first discriminator to obtain the discrimination results for each sample road segment. It also inputs road segment information from multiple reference road segments into the first discriminator to obtain the discrimination results for each reference road segment. Based on the discrimination results of each sample road segment and each reference road segment, the loss value of the first discriminator is determined. Illustratively, the computer device determines the loss value of the first discriminator using the following formula (7).
[0160] Loss D-shape =-∑ d [logD s [(t, p)]-∑ G [1-logD S (t, p)] (7)
[0161] In the above formula (7), Loss D-shape Let ∑ represent the loss value of the first discriminator, log represent the sign of the logarithmic function, and ∑ represent the loss value of the first discriminator. d [logD s [(t, p)] represents the summation of the logarithmic results of the discrimination results for the sample road segments, ∑ G [logD s [(t, p)] represents the sum of 1 minus the logarithm of the discrimination result for the reference road segment. It should be noted that t and p in formula (7) represent the type vector and parameter vector corresponding to the road segment information, respectively.
[0162] In this step, the network parameters of the first discriminator are iteratively updated to minimize the loss value of the first discriminator until the iteration cutoff condition is met, resulting in the updated first discriminator. For example, the iteration cutoff condition for this step is that the loss value of the first discriminator is less than or equal to a preset threshold, or that the number of iterations is greater than or equal to a preset number, etc., and this application is not limited to these.
[0163] Step A2: Input the road segment information of multiple reference road segments into the updated first discriminator, and output the discrimination result of each reference road segment. The discrimination result of the reference road segment indicates whether the reference road segment is a sample road segment.
[0164] After obtaining the updated first discriminator, the road segment information of multiple reference road segments is input into the updated first discriminator to obtain the discrimination results of each reference road segment.
[0165] Step A3: Based on the discrimination results of each reference road segment, determine the loss value of the road segment generator. Based on the loss value of the road segment generator, update the network parameters of the road segment generator to obtain the updated road segment generator.
[0166] The computer equipment determines the loss value of the road segment generator using the following formula (8).
[0167] Loss G =Σ G [1-logD s (t, p)] (8)
[0168] In the above formula (8), Loss G This represents the loss value of the road segment generator; Σ G [1-logD s [(t, p)] represents the sum of the result of subtracting the logarithm of the judgment result of the reference road segment from 1.
[0169] In this step, the network parameters of the road segment generator are iteratively updated to minimize the loss value of the road segment generator until the iteration cutoff condition is met, resulting in an updated road segment generator. It should be understood that this update process includes updating the network parameters of both the first and second generators. This application does not limit the specific form of the iteration cutoff condition corresponding to this step.
[0170] After steps A1 to A3, the first discriminator and the road segment generator are alternately updated in the i-th round. Then, the (i+1)-th round of alternating updates begins, and so on, until the cutoff condition for alternating updates is met, such as the number of alternating update rounds reaching 100, etc., which is not limited. In other words, in any round of alternating updates, the first discriminator is trained first, then the road segment generator is trained, and this process is repeated until the updated first discriminator and the updated road segment generator are obtained.
[0171] In some embodiments, the sample road segments involved in each round of alternating updates are different, and the reference road segments involved in each round of alternating updates are also different. For example, in the i-th round of alternating updates, the computer device generates road segment information for 100 reference road segments based on 100 reference vectors using a road segment generator, and randomly selects 100 sample road segments from multiple sample road segments for use in the i-th round of alternating updates. In the (i+1)-th round of alternating updates, the computer device generates road segment information for 100 new reference road segments based on new 100 reference vectors using a road segment generator, and randomly selects 100 sample road segments again from multiple sample road segments for use in the (i+1)-th round of alternating updates. In this way, the generalization of the road segment generator can be improved, so that no matter what road segment vector is input into the road segment generator, the road segment generator can generate road segment information that is indistinguishable from the real one (or in other words, the first discriminator has difficulty distinguishing between real and fake).
[0172] After steps 602 and 603, the network parameters of the road segment generator were updated, which is equivalent to performing the first stage of training the road segment generation model. Furthermore, since the road segment encoder is not involved in this training stage, or rather, its network parameters remain unchanged, and the reference vectors required to run the road segment generator are randomly sampled from the reference distribution, although the number of sample road segments is limited, the data generated by the road segment generator is massive. This allows for training the road segment generator without requiring a large number of sample road segments, resulting in a human-like road segment design effect.
[0173] It should be noted that this application does not limit the timing of obtaining the reference vectors in steps 602 and 603 above. For example, the reference vectors may be obtained by the computer device sampling the reference distribution before executing step 602, and these reference vectors may be used to update the network parameters of the road segment generator; or, the reference vectors may be obtained by the computer device sampling the reference distribution during each round of alternating updates, and this application is not limited to this.
[0174] 604. The computer equipment encodes the road segment information of the first road segment through the road segment encoder to obtain the road segment vector of the first road segment. Based on the road segment vector of the first road segment, the road segment information of the second road segment is generated by the road segment generator.
[0175] The second road segment refers to the next road segment adjacent to the first road segment. The road segment information of the first road segment can be the road segment information of any sample road segment, or it can be any road segment information generated by the aforementioned updated road segment generator. This application is not limited to this. The process of the road segment encoder encoding the road segment information of the first road segment is described in the above formula (1), and will not be repeated here. In addition, this application does not limit the number of first road segments.
[0176] 605. The computer device alternately updates the network parameters of the road segment encoder and the network parameters of the second discriminator based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, so as to obtain the updated road segment encoder and the updated second discriminator.
[0177] The second discriminator is used to determine whether two adjacent road segments are adjacent sample road segments. That is, given the road segment information of any two adjacent road segments, the second discriminator outputs a discrimination result indicating whether the two road segments are adjacent sample road segments. In this step, the network parameters of the road segment encoder and the second discriminator are updated alternately, employing a generative adversarial algorithm. By repeatedly updating the second discriminator and the road segment encoder alternately, they upgrade each other in an adversarial process, thus completing the training. It should be understood that the second discriminator can be deleted after training, and the trained road segment encoder can be used as part of the road segment generation model to generate road segments.
[0178] Schematic, the second discriminator is also called a road segment connection discriminator (D-link, abbreviated as D). L It can be a three-layer fully connected neural network. For example, the second discriminator is implemented by the following formula (9):
[0179]
[0180] In the above formula (9), t and p are the road segment information of the first road segment, and t′ and p′ are the output results of the road segment generator, that is, the road segment information of the second road segment; That is, it is the input of the first fully connected neural network layer in the second discriminator; matrix W 12 and bias vector b 12 Here are the network parameters for the first layer of the fully connected neural network; matrix W 13 and bias vector b 13 The network parameters for the second fully connected neural network layer; matrix W 14 and bias vector b 14 These are the network parameters for the third fully connected neural network layer; ReLU and sigmoid are both activation functions.
[0181] It should be understood that since the second discriminator can determine whether two adjacent road segments are adjacent sample road segments, if the road segment information of the first road segment and the road segment information of the second road segment generated by the road segment generator are input into the second discriminator, the second discriminator will output that the two sample road segments are not adjacent, for example, by outputting the value "-1"; if the road segment information of two adjacent sample road segments are input into the second discriminator, the second discriminator will output that the two sample road segments are adjacent, for example, by outputting the value "+1". For the road segment encoder, the training objective is to ensure that the road segment vector output by the encoder, after being input into the road segment generator, generates road segment information that closely resembles the sample road segment information, or in other words, possesses similar quality and style. Correspondingly, for the second discriminator, the training objective is to ensure that the road segment information from the first road segment and the second road segment generated by the road segment generator achieves a high output in the second discriminator, for example, an output value approaching "+1". In other words, the training objective is for the second discriminator to classify the first road segment and the second road segment generated by the road segment generator as two adjacent sample road segments. In this way, the road segment generator can generate "deceptively realistic" road segment information. By employing this generative adversarial algorithm, the second discriminator and the road segment encoder are alternately updated multiple times, allowing them to upgrade through adversarial training, thus completing the training and obtaining an updated second discriminator and an updated road segment encoder.
[0182] The following describes the process of the computer device alternately updating the network parameters of the road segment encoder and the network parameters of the second discriminator, taking any round of alternating update as an example (hereinafter referred to as the qth round of alternating update, where q is a positive integer). The process includes steps B1 to B3 below.
[0183] Step B1: Based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, determine the loss value of the second discriminator. Based on the loss value of the second discriminator, update the network parameters of the second discriminator to obtain the updated second discriminator.
[0184] The computer device inputs the road segment information of two adjacent sample road segments into the second discriminator to obtain the discrimination result of the two adjacent sample road segments. It then inputs the road segment information of the first road segment and the road segment information of the second road segment into the second discriminator to obtain the discrimination result of the first road segment and the second road segment. Based on the discrimination results of the two adjacent sample road segments and the discrimination results of the first and second road segments, the loss value of the second discriminator is determined. Illustratively, the computer device determines the loss value of the second discriminator using the following formula (10).
[0185] Loss D-link =-∑ d [logD L[(t, p, t′, p′)]-∑ E,G [l-logD L (t, p, t′, p′)] (10)
[0186] In the above formula (10), Loss D-link Let ∑ represent the loss value of the second discriminator, log represent the sign of the logarithmic function, and ∑ represent the loss value of the second discriminator. d [logD L [(t, p, t′, p′)] represents the sum of the logarithms of the discrimination results for two adjacent sample road segments, ∑ E,G [l-logD L [t, p, t′, p′] represents the sum of 1 minus the logarithm of the judgment results for the first and second road segments.
[0187] In this step, the network parameters of the second discriminator are iteratively updated to minimize the loss value of the second discriminator until the iteration cutoff condition is met, resulting in the updated second discriminator. For example, the iteration cutoff condition for this step is that the loss value of the second discriminator is less than or equal to a preset threshold, or that the number of iterations is greater than or equal to a preset number, etc., and this application is not limited to these.
[0188] Step B2: Input the road segment information of the first road segment and the road segment information of the second road segment into the updated second discriminator, and output the discrimination results of the first road segment and the second road segment. The discrimination results of the first road segment and the second road segment indicate whether the first road segment and the second road segment are two adjacent sample road segments.
[0189] After obtaining the updated second discriminator, the road segment information of the first road segment and the road segment information of the second road segment are input into the updated second discriminator, and the discrimination results of the first road segment and the second road segment are output.
[0190] Step B3: Based on the road segment information of the second road segment and the discrimination results of the first and second road segments, determine the loss value of the road segment encoder. Based on the loss value of the road segment encoder, update the network parameters of the road segment encoder to obtain the updated road segment encoder.
[0191] The computer device inputs the road segment information of the second road segment into the updated first discriminator to obtain the discrimination result of the second road segment. The discrimination result of the second road segment indicates whether the second road segment is a sample road segment. Then, based on the discrimination result of the second road segment, the discrimination results of the first road segment and the second road segment, the computer device determines the loss value of the road segment encoder by the following formula (11).
[0192] Loss E =∑ G [1-logD s [(t′,p′)]+∑E,G [1-logD L (t, p, t′, p′)] (l1)
[0193] In the above formula (11), represents the loss value of the road segment generator, ∑ G [1-logD s [(t′,p′)] represents the sum of the logarithm of the judgment result for the second road segment minus 1, ∑ E,G [1-logD L [t, p, t′, p′] represents the sum of 1 minus the logarithm of the judgment results for the first and second road segments.
[0194] In this step, the network parameters of the road segment encoder are updated iteratively to minimize the loss value of the road segment encoder until the iteration cutoff condition is met, thus obtaining the updated road segment encoder. It should be understood that this application does not limit the specific form of the iteration cutoff condition corresponding to this step.
[0195] After steps B1 to B3, the second discriminator and the road segment encoder are alternately updated for the qth round. Then, the (q+1)th round of alternating updates begins, and so on, until the cutoff condition for alternating updates is met, such as 100 rounds, etc. In other words, in any round of alternating updates, the second discriminator is trained first, then the road segment encoder is trained, and this process is repeated until the updated second discriminator and the updated road segment encoder are obtained.
[0196] In some embodiments, the sample road segments, first road segments, and second road segments involved in each round of alternating updates are different. For example, in the q-th round of alternating updates, the computer device generates road segment information for 100 consecutive road segments using a road segment encoder and a road segment generator. Any two adjacent road segments are designated as the first road segment and the second road segment, resulting in 99 sets of adjacent first road segments and second road segments. 99 sets of adjacent sample road segments are randomly selected from multiple sample road segments and used in the q-th round of alternating updates. In the q+1-th round of alternating updates, the computer device generates new road segment information for 100 consecutive road segments using a road segment encoder and a road segment generator. Any two adjacent road segments are designated as the first road segment and the second road segment, resulting in 99 sets of adjacent first road segments and second road segments. 99 sets of adjacent sample road segments are randomly selected again from multiple sample road segments and used in the q+1-th round of alternating updates. In this way, the generalization ability of the road segment encoder can be improved, so that the road segment information generated by the road segment vector output by the road segment encoder after being input into the road segment generator can be close to the road segment information of the sample road segment, or in other words, have similar quality and style to the sample road segment.
[0197] Following steps 604 and 605, the network parameters of the road segment encoder were updated, which constitutes the second stage of training for the road segment generation model. After obtaining the updated road segment encoder and the updated road segment generator, these are used as the trained road segment generation model in the road segment generation process.
[0198] In addition, based on the above Figure 4 As can be seen from the illustrated embodiments, in other embodiments, the input to the road segment generation model also includes desired road segment information. Accordingly, during the training of the road segment generation model, this application also provides a loss function (also known as a knowledge model R-rule), which is introduced when updating the network parameters of the road segment encoder to improve the model training effect. Schematic, steps 604 and 605 above are replaced by steps 604' and 605' below.
[0199] 604' The computer equipment encodes the desired road segment information and the road segment information of the first road segment through the road segment encoder to obtain the road segment vector of the first road segment. The desired road segment information indicates the road segment information of the second road segment that is expected to be generated by the road segment generator.
[0200] The process of the road segment encoder encoding the desired road segment information and the road segment information of the first road segment is described in the above formula (5), and will not be repeated here.
[0201] 605' The computer device updates the network parameters of the road segment encoder based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, the road segment information of the second road segment, and the difference between the road segment information of the second road segment and the desired road segment information.
[0202] Taking the desired road segment information as a two-dimensional target vector g as an example, the difference between the road segment information of the second road segment and the desired road segment information is calculated by the following formula (12):
[0203] R(g, p′) = 0.5 × (g1 - p′1) 2 +0.5×(g2-p′3) 2 (12)
[0204] In the above formula (12), R(g, p′) represents the difference between the road segment information of the second road segment and the desired road segment information, g1 is the first dimension value of the target vector, representing the desired length of the second road segment, g2 is the second dimension value of the target vector, representing the desired turning angle of the second road segment, p′1 is the first dimension value of the parameter vector p of the second road segment, representing the length of the second road segment, and p′3 is the third dimension value of the parameter vector p of the second road segment, representing the turning angle of the second road segment.
[0205] Furthermore, as can be seen from step 605 above, the computer device uses a generative adversarial algorithm to upgrade the second discriminator and the road segment encoder through repeated alternating updates, thereby completing the training. The same principle applies in this step, so it will not be elaborated further.
[0206] Schematic, the aforementioned formula (11) describes how to determine the loss value of the road segment encoder. Accordingly, after introducing the loss function corresponding to the desired road segment information, the loss value of the road segment encoder can be determined by the following formula (13):
[0207] Loss E =∑ G [l-logD S [(t′,p′)]+∑ E,G [1-logD L (t, p, t′, p′)]+R(g, p′) (13)
[0208] The meaning of each parameter in the above formula (13) is the same as that in the above formula (11), representing the difference between the road segment information of the second road segment and the expected road segment information.
[0209] In this step, the network parameters of the road segment encoder are updated iteratively to minimize the loss value of the road segment encoder until the iteration cutoff condition is met, thus obtaining the updated road segment encoder. It should be understood that this application does not limit the specific form of the iteration cutoff condition corresponding to this step.
[0210] The following is for reference. Figure 7 and Figure 8 Regarding the above Figure 6 The illustrated embodiment is provided as an example. Figure 7 This is a schematic diagram illustrating a training method for a road segment generation model provided in an embodiment of this application. For example... Figure 7 As shown, the training process of the road segment generation model includes: extracting road segment information from multiple sample road segments from existing virtual roads; vectorizing the road segment information (including road segment type and road segment parameters) of each sample road segment; then, using the road segment information of multiple sample road segments, first training the road segment generator, then training the road segment encoder to obtain the trained road segment generation model; and finally deploying the trained road segment generation model to specific applications.
[0211] Figure 8 This is a schematic diagram of another training method for a road segment generation model provided in an embodiment of this application. For example... Figure 8As shown, the training method for the road segment generation model includes two stages: training the road segment generator and training the road segment encoder. In the diagram, the road segment generator includes: a first generator, also known as the road segment type generator (G-type), which generates the road segment type vector t; and a second generator, also known as the road segment parameter generator (G-param), which generates the road segment parameter vector p. The road segment encoder generates the road segment vector, i.e., vector z.
[0212] During the training of the road segment generator, the network parameters of the road segment encoder are kept unchanged. Based on the reference vector (also called vector z) randomly sampled from a uniform distribution, the reference vector is input into the first generator to obtain the type vector t′ of the reference road segment corresponding to the reference vector. The type vector t′ and the reference vector are input into the second generator to obtain the parameter vector p′ of the reference road segment. The type vector t′ and the parameter vector p′ are input into the first discriminator (i.e., D-shape) to obtain the corresponding discrimination result. Based on the aforementioned step 603, if the type vector t′ and parameter vector p′ generated by the road segment generator are input into the first discriminator, the first discriminator will output "-1"; if the road segment information of the sample road segment is input into the first discriminator, the first discriminator will output "+1". Therefore, for the first discriminator, its training objective is to hope that the road segment information generated by the road segment generator can obtain a higher output in the first discriminator, that is, the output value is close to "+1". For the road segment generator, the training objective is to ensure that the road segment information generated by the generator closely approximates the road segment information of the sample road segments, or in other words, possesses similar qualities and style. Through steps 602 and 603 as described above, the network parameters of the road segment generator are updated, completing the first stage of training the road segment generation model. Furthermore, since the road segment encoder is not involved in this training stage, or rather, its network parameters remain unchanged, and the reference vectors required to run the road segment generator are randomly sampled from a reference distribution, although the number of sample road segments is limited, the data generated by the road segment generator is massive. This allows for training the road segment generator without requiring a large amount of sample road segment information, resulting in a human-like road segment design effect.
[0213] During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The desired road segment information (i.e., the target vector g) and the road segment information of the first road segment (type vector t and parameter vector p) are input into the road segment encoder to obtain the road segment vector z of the first road segment. This vector z can then be used to generate the road segment vector of the second road segment, i.e., the type vector t′ and parameter vector p′. Based on the aforementioned step 605, the second discriminator (D-link) accepts four inputs: t, p, t′, and p′. If the road segment information of the first road segment and the road segment information of the second road segment generated by the road segment generator are input into the second discriminator, the second discriminator will output the value "-1"; if the road segment information of two adjacent sample road segments are input into the second discriminator, the second discriminator will output "+1". Therefore, for the second discriminator, its training objective is to obtain a higher output in the second discriminator from the road segment information of the first road segment and the road segment information of the second road segment generated by the road segment generator, i.e., the output value should approach "+1". For the road segment encoder, the training objective is to ensure that the road segment vector output by the encoder, after being input into the road segment generator, generates road segment information that closely resembles, or in other words, possesses similar quality and style to, the sample road segments. Through steps 604 and 605 described above, the network parameters of the road segment encoder are updated, completing the second stage of training the road segment generation model. In this process, the aforementioned knowledge model R-rule is used to determine the difference between the desired road segment information and the information of the second road segment, and this difference is applied to the training process. In this way, the road segment encoder can learn the correlation between two adjacent sample road segments, thereby encoding road segment information more accurately and obtaining road segment vectors. Inputting these road segment vectors into the trained road segment generator improves the quality of the road segment information generated by the generator.
[0214] In summary, the training method for the road segment generation model provided in this application involves a road segment generation model including a road segment encoder and a road segment generator. During training, the network parameters of the road segment encoder are first fixed, and the network parameters of the road segment generator are updated. Then, the network parameters of the road segment generator are fixed, and the network parameters of the road segment encoder are updated. Since both the road segment generator and the road segment encoder can generate a large amount of data, the entire training process does not depend on the number of sample road segments. Therefore, there is no need to worry about model overfitting caused by insufficient sample road segments. The trained road segment generation model can quickly generate new road segments similar to the sample road segments, improving road segment generation efficiency.
[0215] The following is for reference. Figure 9 This paper introduces the road segment generation method provided in this application.
[0216] Figure 9This is a flowchart of a road segment generation method provided in an embodiment of this application. Figure 9 As shown, the method is performed by a computer device, which can provide the above-described... Figure 1 The terminal or server shown is schematically illustrated, and the method includes the following steps 901 to 903.
[0217] 901. Computer equipment obtains road segment information.
[0218] Here, "road segment" refers to any section of a road. For example, in the animation production scene of a racing game, a road segment could be the current end of the track; this application is not limited to this. Road segment information is provided above. Figures 4 to 8 The embodiments shown are not described in detail here.
[0219] 902. The computer equipment encodes the road segment information through the road segment encoder of the road segment generation model to obtain the road segment vector.
[0220] Among them, the road segment generation model is as described above. Figures 4 to 8 The training was achieved using any of the available training methods, which will not be elaborated upon here.
[0221] In some embodiments, the computer device acquires desired road segment information, which indicates the road segment information of the next road segment to be generated by the road segment generator of the road segment generation model. Accordingly, this step includes encoding the desired road segment information and the road segment information of the current road segment using a road segment encoder to obtain a road segment vector. By also including the desired road segment information as input to the road segment generation model, the accuracy of the output of the road segment generation model can be improved.
[0222] 903. The computer equipment uses the road segment generator of the road segment generation model to generate road segment information of the next road segment adjacent to the existing road segment, based on the road segment vector of the existing road segment.
[0223] Taking road segment information, which includes road segment type and road segment parameters, as an example, the computer device extracts the road segment type of the next road segment from the road segment information of the next road segment; extracts the road segment parameters of the next road segment from the road segment information of the next road segment; and generates the next road segment based on the road segment type and the road segment parameters of the next road segment.
[0224] Indicatively, for reference Figure 10 , Figure 10 This is a schematic diagram of a road segment generation method provided in an embodiment of this application. For example... Figure 10As shown, when generating road segments using the trained road segment generation model, the desired road segment information (target vector g) and the existing road segment information (type vector t and parameter vector p) are input into the road segment encoder. The encoder encodes the information to obtain the road segment vector z. This vector z is then input into the first generator to obtain the type vector t′ of the next road segment. Finally, the type vector t′ and the road segment vector z are input into the second generator to obtain the parameter vector p′ of the next road segment, thus obtaining the road segment information for the next segment. It should be understood that the above process is illustrated using the generation of a single road segment as an example. In scenarios involving the batch generation of multiple road segments, by iteratively executing the above process, multiple consecutive road segments can be automatically generated. Combining these multiple road segments yields a complete virtual road.
[0225] As can be seen, the road segment generation model provided in this application can generate a large number of road segments in a short time, and endow them with the style and quality of existing road segments, thereby reducing the manpower cost and labor intensity of road segment generation and improving the development efficiency of virtual roads. At the same time, the training process of the above-mentioned road segment generation model does not need to worry about overfitting caused by insufficient sample road segments, thus greatly improving the human-likeness, usability and rationality of the model output results.
[0226] Figure 11 This is a schematic diagram of a training device for a road segment generation model provided in an embodiment of this application. This device is used to execute the steps of the training method for the road segment generation model described above, see below. Figure 11 The device includes an acquisition module 1101 and a training module 1102.
[0227] The acquisition module 1101 is used to acquire the road segment generation model and the road segment information of multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator. The road segment encoder is used to encode the road segment information of the road segment to obtain the road segment vector of the road segment. The road segment generator is used to generate the road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment.
[0228] Training module 1102 is used to train the road segment generator and the road segment encoder sequentially based on the road segment information of multiple sample road segments;
[0229] In the process of training the road segment generator, the network parameters of the road segment encoder are kept unchanged. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments, the network parameters of the road segment generator are updated.
[0230] During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the first input road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment.
[0231] In some embodiments, the training module 1102 includes a first training unit, which is configured to:
[0232] The road segment generator generates road segment information corresponding to each reference vector based on multiple reference vectors. The reference vectors are obtained by sampling the reference distribution of the road segment vectors.
[0233] Based on the road segment information of multiple sample road segments and multiple reference road segments, the network parameters of the road segment generator and the network parameters of the first discriminator are updated alternately to obtain the updated road segment generator and the updated first discriminator. The first discriminator is used to determine whether a road segment is a sample road segment.
[0234] In some embodiments, the reference distribution of the road segment vector is a uniform distribution, and the reference vector is obtained by randomly sampling the uniform distribution.
[0235] In some embodiments, the first training unit is used for:
[0236] In the i-th round of alternating updates, the loss value of the first discriminator is determined based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments. Based on the loss value of the first discriminator, the network parameters of the first discriminator are updated to obtain the updated first discriminator, where i is a positive integer.
[0237] The road segment information of multiple reference road segments is input into the updated first discriminator, and the discrimination result of each reference road segment is output. The discrimination result of the reference road segment indicates whether the reference road segment is a sample road segment.
[0238] Based on the discrimination results of each reference road segment, the loss value of the road segment generator is determined. Based on the loss value of the road segment generator, the network parameters of the road segment generator are updated to obtain the updated road segment generator.
[0239] In some embodiments, the training module 1102 includes a second training unit, the second training unit being configured to:
[0240] The road segment information of the first road segment is encoded by the road segment encoder to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment.
[0241] Based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, the network parameters of the road segment encoder and the network parameters of the second discriminator are updated alternately to obtain the updated road segment encoder and the updated second discriminator. The second discriminator is used to determine whether two adjacent road segments are adjacent sample road segments.
[0242] In some embodiments, the second training unit is used for:
[0243] In the qth round of alternating updates, the loss value of the second discriminator is determined based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. Based on the loss value of the second discriminator, the network parameters of the second discriminator are updated to obtain the updated second discriminator, where q is a positive integer.
[0244] The road segment information of the first road segment and the road segment information of the second road segment are input into the updated second discriminator, and the discrimination results of the first road segment and the second road segment are output. The discrimination results of the first road segment and the second road segment indicate whether the first road segment and the second road segment are two adjacent sample road segments.
[0245] Based on the road segment information of the second road segment and the discrimination results of the first and second road segments, the loss value of the road segment encoder is determined. Based on the loss value of the road segment encoder, the network parameters of the road segment encoder are updated to obtain the updated road segment encoder.
[0246] In some embodiments, the training module 1102 is used to encode the desired road segment information and the road segment information of the first road segment through a road segment encoder to obtain the road segment vector of the first road segment, wherein the desired road segment information indicates the road segment information of the second road segment expected to be generated by the road segment generator.
[0247] In some embodiments, the training module 1102 is used for:
[0248] The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, the road segment information of the second road segment, and the difference between the road segment information of the second road segment and the expected road segment information.
[0249] In some embodiments, the road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters;
[0250] The first generator is used to generate the road segment type of the next road segment adjacent to the road segment based on the road segment vector of the road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the road segment and the road segment type of the next road segment.
[0251] With the aforementioned device, since the road segment generator and road segment encoder can generate a large amount of data, the entire training process does not depend on the number of sample road segments. Therefore, there is no need to worry about model overfitting caused by insufficient sample road segments. The trained road segment generation model can quickly generate new road segments similar to the sample road segments, thus improving the efficiency of road segment generation.
[0252] It should be noted that the training device for the road segment generation model provided in the above embodiments is only illustrated by the division of the above functional modules when training the road segment generation model. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the training device for the road segment generation model provided in the above embodiments and the training method embodiment for the road segment generation model belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0253] Figure 12 This is a schematic diagram of a road segment generation device provided in an embodiment of this application. This device is used to perform the steps of the road segment generation method described above. (See attached diagram.) Figure 12 The device includes: an acquisition module 1201, an encoding module 1202, and a generation module 1203.
[0254] The acquisition module 1201 is used to acquire road segment information.
[0255] The encoding module 1202 is used to encode the road segment information of the road segment through the road segment encoder of the road segment generation model to obtain the road segment vector of the road segment. The road segment generation model is trained according to the training method of the road segment generation model provided in this application.
[0256] The generation module 1203 is used to generate a road segment generator for the road segment generation model, which generates road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment.
[0257] In some embodiments, the acquisition module 1201 is further configured to:
[0258] Obtain the desired road segment information, which indicates the road segment information expected to be generated by the road segment generator;
[0259] Encoding module 1202 is used for:
[0260] The desired road segment information and the road segment information are encoded by the road segment encoder to obtain the road segment vector.
[0261] In some embodiments, the road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters;
[0262] The first generator is used to generate the road segment type of the next road segment based on the road segment vector of the road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the road segment and the road segment type of the next road segment.
[0263] In some embodiments, the apparatus further includes:
[0264] The extraction module is used to extract the road segment type of the next road segment from the road segment information of the next road segment; and to extract the road segment parameters of the next road segment from the road segment information of the next road segment.
[0265] The road segment generation module is used to generate the next road segment based on the road segment type and road segment parameters of the next road segment.
[0266] Using the aforementioned device, the road segment generation model provided in this application can generate a large number of road segments in a short time, and imbue them with the style and quality of existing road segments, thereby reducing the manpower cost and labor intensity of road segment generation and improving the development efficiency of virtual roads. Furthermore, the training process of the aforementioned road segment generation model does not need to worry about overfitting due to insufficient sample road segments, thus greatly improving the human-likeness, usability, and rationality of the model's output results.
[0267] It should be noted that the road segment generation device provided in the above embodiments is only illustrated by the division of the above functional modules when generating road segments. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the road segment generation device and the road segment generation method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0268] In an exemplary embodiment, a computer device is also provided, the computer device including a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded and executed by the processor to implement the training method of the road segment generation model in the embodiments of this application, or to implement the road segment generation method in the embodiments of this application.
[0269] Taking computer devices as terminals as an example, Figure 13This is a schematic diagram of the structure of a terminal provided in an embodiment of this application. The terminal 1300 can be: a smartphone, tablet computer, MP3 player (Moving Picture Experts Group Audio Layer III), MP4 player (Moving Picture Experts Group Audio Layer IV), laptop computer, or desktop computer. The terminal 1300 may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0270] Typically, terminal 1300 includes a processor 1301 and a memory 1302.
[0271] Processor 1301 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1301 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1301 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1301 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the screen. In some embodiments, processor 1301 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0272] The memory 1302 may include one or more computer-readable storage media, which may be non-transitory. The memory 1302 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1302 are used to store at least one program code, which is executed by the processor 1301 to implement the training method of the road segment generation model provided in the method embodiments of this application, or to implement the road segment generation method provided in the embodiments of this application.
[0273] In some embodiments, the terminal 1300 may also optionally include a peripheral device interface 1303 and at least one peripheral device. The processor 1301, memory 1302, and peripheral device interface 1303 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 1303 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of the following: a radio frequency circuit 1304, a display screen 1305, a camera assembly 1306, an audio circuit 1307, a positioning assembly 1308, and a power supply 1309.
[0274] Peripheral device interface 1303 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 1301 and memory 1302. In some embodiments, processor 1301, memory 1302 and peripheral device interface 1303 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 1301, memory 1302 and peripheral device interface 1303 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0275] The radio frequency (RF) circuit 1304 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 1304 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 1304 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 1304 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 1304 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 1304 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0276] Display screen 1305 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 1305 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 1301 for processing. In this case, display screen 1305 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 1305, disposed on the front panel of terminal 1300; in other embodiments, there may be at least two display screens, disposed on different surfaces of terminal 1300 or in a folded design; in still other embodiments, display screen 1305 may be a flexible display screen, disposed on a curved or folded surface of terminal 1300. Furthermore, display screen 1305 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. The display screen 1305 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
[0277] The camera assembly 1306 is used to acquire images or videos. Optionally, the camera assembly 1306 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 1306 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0278] The audio circuit 1307 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 1301 for processing, or input to the radio frequency circuit 1304 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each located at a different part of the terminal 1300. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert electrical signals from the processor 1301 or the radio frequency circuit 1304 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 1307 may also include a headphone jack.
[0279] The positioning component 1308 is used to locate the current geographical location of the terminal 1300 in order to enable navigation or LBS (Location Based Service).
[0280] Power supply 1309 is used to power the various components in terminal 1300. Power supply 1309 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 1309 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0281] In some embodiments, the terminal 1300 further includes one or more sensors 1310. The one or more sensors 1310 include, but are not limited to: an acceleration sensor 1311, a gyroscope sensor 1312, a pressure sensor 1313, an optical sensor 1314, and a proximity sensor 1315.
[0282] Accelerometer 1311 can detect the magnitude of acceleration along the three axes of a coordinate system established by terminal 1300. For example, accelerometer 1311 can be used to detect the components of gravitational acceleration along the three axes. Processor 1301 can control display screen 1305 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 1311. Accelerometer 1311 can also be used for games or for acquiring user motion data.
[0283] The gyroscope sensor 1312 can detect the orientation and rotation angle of the terminal 1300. The gyroscope sensor 1312, in conjunction with the accelerometer sensor 1311, can collect 3D motion data from the user on the terminal 1300. Based on the data collected by the gyroscope sensor 1312, the processor 1301 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0284] The pressure sensor 1313 can be disposed on the side bezel of the terminal 1300 and / or on the lower layer of the display screen 1305. When the pressure sensor 1313 is disposed on the side bezel of the terminal 1300, it can detect the user's grip signal on the terminal 1300, and the processor 1301 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 1313. When the pressure sensor 1313 is disposed on the lower layer of the display screen 1305, the processor 1301 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 1305. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0285] Optical sensor 1314 is used to collect ambient light intensity. In one embodiment, processor 1301 can control the display brightness of display screen 1305 based on the ambient light intensity collected by optical sensor 1314. Specifically, when the ambient light intensity is high, the display brightness of display screen 1305 is increased; when the ambient light intensity is low, the display brightness of display screen 1305 is decreased. In another embodiment, processor 1301 can also dynamically adjust the shooting parameters of camera assembly 1306 based on the ambient light intensity collected by optical sensor 1314.
[0286] The proximity sensor 1315, also known as a distance sensor, is typically located on the front panel of the terminal 1300. The proximity sensor 1315 is used to detect the distance between the user and the front of the terminal 1300. In one embodiment, when the proximity sensor 1315 detects that the distance between the user and the front of the terminal 1300 is gradually decreasing, the processor 1301 controls the display screen 1305 to switch from a screen-on state to a screen-off state; when the proximity sensor 1315 detects that the distance between the user and the front of the terminal 1300 is gradually increasing, the processor 1301 controls the display screen 1305 to switch from a screen-off state to a screen-on state.
[0287] Those skilled in the art will understand that Figure 13 The structure shown does not constitute a limitation on terminal 1300 and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0288] Taking computer equipment as a server as an example, Figure 14 This is a schematic diagram of a server structure provided in an embodiment of this application. The server 1400 can vary significantly due to different configurations or performance, and may include one or more Central Processing Units (CPUs) 1401 and one or more memories 1402. The memories 1402 store at least one computer program, which is loaded and executed by the processor 1401 to implement the training method for the road segment generation model provided in the above-described method embodiments, or to implement the road segment generation method in the embodiments of this application. Of course, the server 1400 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server 1400 may also include other components for implementing device functions, which will not be elaborated here.
[0289] This application also provides a computer-readable storage medium applied to a computer device. The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the training method of the road segment generation model in the above embodiments, or to implement the road segment generation method in the embodiments of this application.
[0290] This application also provides a computer program product comprising at least one computer program stored in a computer-readable storage medium. A processor of a computer device reads the at least one computer program from the computer-readable storage medium and executes the at least one computer program, causing the computer device to perform either the training method for the road segment generation model in this application embodiment or the road segment generation method in this application embodiment.
[0291] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0292] The above description is merely an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A training method for a road segment generation model, characterized in that, The method includes: The method obtains a road segment generation model and road segment information of multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator. The road segment encoder is used to encode the road segment information of the road segment to obtain the road segment vector of the road segment. The road segment generator is used to generate the road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment. Based on the road segment information of multiple sample road segments, the road segment generator and the road segment encoder are trained sequentially; During the training of the road segment generator, the network parameters of the road segment encoder are kept unchanged. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments, the network parameters of the road segment generator are updated. During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the input first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment.
2. The method according to claim 1, characterized in that, The process involves generating road segment information for multiple reference road segments using the road segment generator, and updating the network parameters of the road segment generator based on the road segment information of the multiple sample road segments and the road segment information of the multiple reference road segments, including: The road segment generator generates road segment information corresponding to each reference vector based on multiple reference vectors. The reference vectors are obtained by sampling the reference distribution of the road segment vectors. Based on the road segment information of multiple sample road segments and multiple reference road segments, the network parameters of the road segment generator and the network parameters of the first discriminator are alternately updated to obtain the updated road segment generator and the updated first discriminator. The first discriminator is used to determine whether a road segment is a sample road segment.
3. The method according to claim 2, characterized in that, The reference distribution of the road segment vector is a uniform distribution, and the reference vector is obtained by randomly sampling the uniform distribution.
4. The method according to claim 2, characterized in that, The step of alternately updating the network parameters of the road segment generator and the network parameters of the first discriminator based on road segment information from multiple sample road segments and multiple reference road segments to obtain updated road segment generators and updated first discriminators includes: In the i-th round of alternating updates, the loss value of the first discriminator is determined based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments. Based on the loss value of the first discriminator, the network parameters of the first discriminator are updated to obtain the updated first discriminator, where i is a positive integer. The road segment information of multiple reference road segments is input into the updated first discriminator, and the discrimination result of each reference road segment is output. The discrimination result of the reference road segment indicates whether the reference road segment is the sample road segment. Based on the discrimination results of each reference road segment, the loss value of the road segment generator is determined. Based on the loss value of the road segment generator, the network parameters of the road segment generator are updated to obtain the updated road segment generator.
5. The method according to claim 1, characterized in that, The process involves encoding the road segment information of the input first road segment using the road segment encoder to obtain a road segment vector for the first road segment; generating road segment information for the second road segment using the road segment generator based on the road segment vector of the first road segment; and updating the network parameters of the road segment encoder based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. This includes: The road segment encoder encodes the road segment information of the first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. Based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, the network parameters of the road segment encoder and the network parameters of the second discriminator are alternately updated to obtain the updated road segment encoder and the updated second discriminator. The second discriminator is used to determine whether two adjacent road segments are two adjacent sample road segments.
6. The method according to claim 5, characterized in that, The step of alternately updating the network parameters of the road segment encoder and the network parameters of the second discriminator based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment, to obtain the updated road segment encoder and the updated second discriminator, includes: In the qth round of alternating updates, the loss value of the second discriminator is determined based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. Based on the loss value of the second discriminator, the network parameters of the second discriminator are updated to obtain the updated second discriminator, where q is a positive integer. The road segment information of the first road segment and the road segment information of the second road segment are input into the updated second discriminator, and the discrimination results of the first road segment and the second road segment are output. The discrimination results of the first road segment and the second road segment indicate whether the first road segment and the second road segment are two adjacent sample road segments. Based on the road segment information of the second road segment and the discrimination results of the first road segment and the second road segment, the loss value of the road segment encoder is determined. Based on the loss value of the road segment encoder, the network parameters of the road segment encoder are updated to obtain the updated road segment encoder.
7. The method according to any one of claims 1 to 6, characterized in that, The step of encoding the road segment information of the input first road segment using the road segment encoder to obtain the road segment vector of the first road segment includes: The road segment encoder encodes the desired road segment information and the road segment information of the first road segment to obtain the road segment vector of the first road segment. The desired road segment information indicates the road segment information of the second road segment that is expected to be generated by the road segment generator.
8. The method according to claim 7, characterized in that, The step of updating the network parameters of the road segment encoder based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment includes: The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, the road segment information of the second road segment, and the difference between the road segment information of the second road segment and the expected road segment information.
9. The method according to any one of claims 1 to 6, characterized in that, The road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters; The first generator is used to generate the road segment type of the next road segment adjacent to the road segment based on the road segment vector of the road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the road segment and the road segment type of the next road segment.
10. A method for generating road segments, characterized in that, The method includes: Obtain road segment information; The road segment information of the road segment is encoded by the road segment encoder of the road segment generation model to obtain the road segment vector of the road segment. The road segment generation model is trained according to the training method of the road segment generation model according to any one of claims 1 to 9. The road segment generator of the road segment generation model generates road segment information for the next road segment adjacent to the road segment based on the road segment vector of the road segment.
11. The method according to claim 10, characterized in that, The method further includes: Obtain desired road segment information, wherein the desired road segment information indicates the road segment information of the next road segment expected to be generated by the road segment generator; The road segment encoder of the road segment generation model encodes the road segment information to obtain the road segment vector, including: The road segment encoder encodes the desired road segment information and the road segment information of the road segment to obtain the road segment vector.
12. The method according to claim 10, characterized in that, The road segment generator includes a first generator and a second generator, and the road segment information includes road segment type and road segment parameters; The first generator is used to generate the road segment type of the next road segment based on the road segment vector of the previous road segment; the second generator is used to generate the road segment parameters of the next road segment based on the road segment vector of the previous road segment and the road segment type of the next road segment.
13. The method according to claim 12, characterized in that, The method further includes: Extract the road segment type of the next road segment from the road segment information of the next road segment; Extract the road segment parameters of the next road segment from the road segment information of the next road segment; The next road segment is generated based on the road segment type and the road segment parameters of the next road segment.
14. A training device for a road segment generation model, characterized in that, The device includes: The acquisition module is used to acquire road segment information of a road segment generation model and multiple sample road segments. The road segment generation model includes a road segment encoder and a road segment generator. The road segment encoder is used to encode the road segment information of the road segment to obtain the road segment vector of the road segment. The road segment generator is used to generate the road segment information of the next road segment adjacent to the road segment based on the road segment vector of the road segment. The training module is used to train the road segment generator and the road segment encoder sequentially based on the road segment information of multiple sample road segments; During the training of the road segment generator, the network parameters of the road segment encoder are kept unchanged. The road segment generator generates road segment information for multiple reference road segments. Based on the road segment information of multiple sample road segments and the road segment information of multiple reference road segments, the network parameters of the road segment generator are updated. During the training of the road segment encoder, the network parameters of the road segment generator remain unchanged. The road segment encoder encodes the road segment information of the input first road segment to obtain the road segment vector of the first road segment. The road segment generator generates the road segment information of the second road segment based on the road segment vector of the first road segment. The network parameters of the road segment encoder are updated based on the road segment information of two adjacent sample road segments, the road segment information of the first road segment, and the road segment information of the second road segment. The second road segment refers to the next road segment adjacent to the first road segment.
15. A road segment generation device, characterized in that, The device includes: The acquisition module is used to acquire road segment information. The encoding module is used to encode the road segment information of the road segment through the road segment encoder of the road segment generation model to obtain the road segment vector of the road segment, wherein the road segment generation model is trained according to the training method of the road segment generation model according to any one of claims 1 to 9; The generation module is used to generate a road segment generator based on the road segment vector of the road segment, and generate road segment information of the next road segment adjacent to the road segment.
16. A computer device, characterized in that, The computer device includes a processor and a memory, the memory being used to store at least one computer program, the at least one computer program being loaded and executed by the processor to enable the computer device to implement the training method for the road segment generation model as described in any one of claims 1 to 9, or to implement the road segment generation method as described in any one of claims 10 to 13.
17. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the training method for the road segment generation model as described in any one of claims 1 to 9, or to implement the road segment generation method as described in any one of claims 10 to 13.
18. A computer program product, characterized in that, The computer program product includes at least one computer program, which is loaded and executed by a processor to implement the training method of the road segment generation model as described in any one of claims 1 to 9, or to implement the road segment generation method as described in any one of claims 10 to 13.