<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Balaji Kamakoti on Medium]]></title>
        <description><![CDATA[Stories by Balaji Kamakoti on Medium]]></description>
        <link>https://medium.com/@bkamakot?source=rss-ad11aea5ba40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*w2ltfr8UBAGqpY5nHBrXWg.jpeg</url>
            <title>Stories by Balaji Kamakoti on Medium</title>
            <link>https://medium.com/@bkamakot?source=rss-ad11aea5ba40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:06:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bkamakot/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Optimize Knowledge Graph Embeddings with DGL-KE]]></title>
            <link>https://medium.com/data-science/optimize-knowledge-graph-embeddings-with-dgl-ke-1fff4ab275f2?source=rss-ad11aea5ba40------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fff4ab275f2</guid>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Balaji Kamakoti]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 13:47:59 GMT</pubDate>
            <atom:updated>2020-06-15T13:47:59.506Z</atom:updated>
            <content:encoded><![CDATA[<h4>Learn about software optimizations to accelerate training Knowledge Graph Embeddings and train your first model in minutes with DGL-KE</h4><p>Authors: Cyrus Vahid, Principal Solutions Engineer, Da Zheng, George Karypis and Balaji Kamakoti: AWS AI</p><h3>Introduction</h3><p>In our <a href="https://medium.com/@bkamakot/introduction-to-knowledge-graph-embedding-with-dgl-ke-77ace6fb60ef">previous post</a>, we introduced the concept of Knowledge Graph Embeddings (KGEs) and two popular models used to generate them in DGL-KE. This blog outlines how DGL-KE accelerates KGE training. We also share an example that readers can run on their local machines.</p><h3>What is DGL-KE</h3><p>To recap, <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> is a high performance, easy-to-use, and scalable toolkit to generate knowledge graph embeddings from large graphs. It is built on top of the <a href="https://www.dgl.ai/">Deep Graph Library</a> (DGL), an open-source library to implement Graph Neural Networks (GNN).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*3-UooJr-hfWWQLwFwGO6wQ.png" /></figure><p>As illustrated in the picture above, <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> implements some of the most popular knowledge embedding models such as TransE, TransR, RotateE, DistMulti, RESCAL, and ComplEx.</p><h3>Challenges</h3><p>Though there are a variety of models available to generate embeddings, training these embeddings is either time consuming or infeasible for large graphs because of two main reasons:</p><ul><li><strong>Size</strong>: Many knowledge graphs have millions of nodes, billion of edges, and tens of thousands of relations. Training embeddings for graphs of this scale requires compute resources that far exceed the capabilities of any single machine. As a result, the computations have to be spread across different devices. This is especially difficult because these devices need to balance the workload and reduce data movement overhead.</li><li><strong>Sparsity</strong>: Knowledge graphs usually have many missing edges and some of the relations are observed infrequently. This makes it difficult to train the embeddings of entities involved in few relations and the embeddings of relations that are observed infrequently.</li></ul><p>The rest of this blog explores these optimizations implemented in DGL-KE to address these challenges. But before we explore these optimizations, let’s review the hardware infrastructure required to train KGEs.</p><h3>Hardware requirements</h3><p>Training KGEs on large graphs requires large amounts of hardware resources, such as multicore CPU machines, multi-GPU machines and a cluster of machines. The three main configurations supported today are:</p><ul><li>Single shared-memory multicore machine (<strong><em>multicore</em></strong>), where several cores on the same machine are used for training.</li><li>Single shared-memory multicore machine with multiple GPUs (<strong><em>multi-GPU</em></strong>), where several GPUs on the same machine are used.</li><li>A cluster of multicore machines (<strong><em>distributed</em></strong>), where multiple shared-memory multicore machines CPU machines are used to train an embedding.</li></ul><p><a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> provides unified software optimizations for all of these hardware configurations to train KGE efficiently.</p><h3>Overview of KGE training</h3><p>For all hardware configurations, the training process starts with a preprocessing step to partition a KG and follows with mini-batch training. You can learn more about mini-batch training using this <a href="https://machinelearningmastery.com/gentle-introduction-mini-batch-gradient-descent-configure-batch-size/">resource</a>. The partitioning step assigns a disjoint set of triplets in a KG to a device. Mini-batch training executes the following steps:</p><ul><li>Samples triplets from the local partition that belongs to a process to form a mini-batch and constructs negative samples for the positive triplets.</li><li>Fetches entity and relation embeddings involved in the mini-batch from the global entity and relation embedding tensors.</li><li>Performs forward and back-propagation on the embeddings fetched in the previous step to compute the gradients of the embeddings.</li><li>Apply the gradients to update the embeddings involved in the mini-batch. This step requires application of an optimization algorithm to adjust the gradients and gradients to written back to the global entity and relation embedding tensors.</li></ul><p><a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> deploys optimizations on each of these steps to accelerate training.</p><h3>Optimizing the data distribution</h3><p>During the training process, mini-batch computation on each device needs to access the data associated with the KG — the entity and relation embeddings. Placing this data at the right location, and coordinating its access and updates are essential to DGL-KE’s performance.</p><ul><li>In multicore systems, the entity and relation embeddings reside in the system’s shared memory. All processes can efficiently access it to generate the mini-batches, read the embeddings, and update them.</li><li>In the case of multi-GPU systems, as entity embeddings are too large to fit into GPU memory, they are kept on the multi-core system’s shared memory along with the knowledge graph. Relation embeddings, however, are stored onto the GPU memory in order to reduce the data transfer. GPU processes read and update the entity embeddings involved in a mini-batch from the multi-core system’s shared memory.</li><li>Training on distributed systems is different as we need to split the data and maximize data locality for each machine. DGL-KE achieves this by using a min-cut graph partitioning algorithm to split the knowledge graph across the machines in a way that balances the load and minimizes the communication. In addition, it uses a per-machine KV-store server to store the embeddings of the entities corresponding to the nodes assigned to it. The trainer process then uses <em>push</em> and <em>pull</em> API to fetch the embedding data and send the updates (gradients) back.</li></ul><p>The figure below graphically illustrates these data distributions are executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YR3gtOVnDbGNfXq-gUZU9A.png" /></figure><h3>Negative sampling</h3><p><a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> constructs a large number of negative samples for each triplet. Sampling is always performed using the system CPU. If negative samples are constructed independently, it will result in accessing a large number of entities across hardware. To reduce data communication, we jointly sample negative edges for edges in a batch so that the number of entities accessed in a batch does not increase dramatically by negative sampling.<br> <br>Simply performing a uniform sample from heads and tails and ignoring the degree of each node, the number of edges that are connected to a node, results in <em>easy</em> negative samples. As nodes with higher degree require more data to discover more patterns about them, we perform negative sampling proportional to degree of nodes. This results in creation of <em>hard</em> negative samples. These hard negative samples often improve the quality of KG embeddings.</p><h3>Partitioning relations</h3><p>The larger the ratio of actual relations in a KG relative to the batch size (≈1000≈1000), the sparser the relation embedding. <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> employs sparse relation embedding reads and updates for communication efficiency. In multi-GPU training, <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> partitions relations into groups and assigns a group to a GPU to reduce data communication between CPU and GPUs.</p><h3>Gradient updates</h3><p><a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> uses CPUs to sample mini-batches and loads entity embeddings before sending them to GPUs for computing gradients. Once a GPU has finished computing the embeddings’ gradients, it sends them to the CPU to update the corresponding embeddings. This means if a process runs serially, the GPU has to wait for the CPU to create a mini-batch and write gradients to the embeddings. To prevent GPU idling, <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> overlaps mini-batch creation and gradient updates in CPUs with mini-batch computation in GPUs.</p><p>Due to relation partitioning, <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> keeps relation embeddings in GPUs and updates them separately from the entity embeddings in CPU. Updating entity embeddings is offloaded to a dedicated process per trainer. This optimization provides a 40% speedup for many KGE models on the <a href="https://www.microsoft.com/en-us/download/details.aspx?id=52312">Freebase dataset</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*qxjYETbmAZB3NA6VUdv-wg.png" /></figure><h3>Training your first Knowledge Graph embedding</h3><h3>Installing DGL-KE</h3><p>If you have <a href="https://docs.conda.io/en/latest/">conda</a> installed on your machine, create an environment using the following command:</p><pre>:~$conda create -n dgl_pytorch python==3.8</pre><pre>:~$conda activate dgl_pytorch</pre><pre>(dgl_pytorch)…:~$</pre><p>Install the appropriate version of <a href="https://pytorch.org/">PyTorch</a> on your machine. If you are using Mac, you can use</p><pre>(dgl_pytorch)…:~$conda install PyTorch torchvision -c PyTorch</pre><p>I am using an Ubuntu machine with 4 GPUs and CUDA 10.0, so I am running:</p><pre>(dgl_pytorch)…:~$conda install PyTorch torchvision cudatoolkit=10 -c PyTorch`</pre><p>Test your installation</p><pre>(dgl_pytorch)…:~$python — version` #should output Python 3.8.0</pre><pre>(dgl_pytorch)…:~$python</pre><pre>&gt;&gt;&gt;import torch</pre><pre>torch.__version__ #outputs the version number of PyTorch you have installed. Mine is ‘1.5.0’</pre><pre>&gt;&gt;&gt;quit()</pre><p>Install <a href="https://www.dgl.ai/pages/start.html">DGL</a> and <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a>:</p><pre>(dgl_pytorch)…:~$pip install dgl dglke</pre><p>Test your installation</p><pre>(dgl_pytorch)…:~$python</pre><pre>&gt;&gt;&gt; import dgl&gt;&gt;&gt; import dglke&gt;&gt;&gt; dgl.__version__, dglke.__version__ #It should output versions of dgl and dglke respectively. Mine is: (‘0.4.3post2’, ‘0.1.0’)</pre><pre>&gt;&gt;&gt;quit()</pre><h3>Let’s run a quick test</h3><pre># create a new workspace</pre><pre>(dgl_pytorch)…:~$mkdir my_task &amp;&amp; cd my_task# Train transE model on FB15k dataset</pre><pre>(dgl_pytorch)…my_task:~$DGLBACKEND=pytorch</pre><pre>(dgl_pytorch)…my_task:~$dglke_train — model_name TransE_l2 — dataset FB15k — batch_size 1000 \</pre><pre> — neg_sample_size 200 — hidden_dim 400 — gamma 19.9 — lr 0.25 — max_step 500 — log_interval 100 \</pre><pre> — batch_size_eval 16 -adv — regularization_coef 1.00E-09 — test — num_thread 1 — num_proc 8</pre><pre> — — — — — — — Test result — — — — — — — </pre><pre>Test average MRR : 0.47339627234644155</pre><pre>Test average MR : 58.33693352067851</pre><pre>Test average HITS@1 : 0.2806791826784717</pre><pre>Test average HITS@3 : 0.6246889336561088</pre><pre>Test average HITS@10 : 0.7729342655448528</pre><pre> — — — — — — — — — — — — — — — — — — — — -</pre><h3>What just happened?</h3><p>First, we set the <a href="https://www.dgl.ai/pages/start.html">DGL</a>’s backend to be <a href="https://pytorch.org/">PyTorch</a>. We then created a training task using dglke-train. This training task uses TransE with L2 loss, downloads FB15k dataset. We then instructed the model to build k=200k=200 negative samples with γ=400 for embedding dimension, 1000 for the mini-batch size (batch_size 1000), and with batch_size_eval=16 as hyper-parameter used for the test.</p><h3>What’s next?</h3><p>Learn more about <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> and <a href="https://www.dgl.ai/">DGL</a>, and stay tuned for additional examples.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fff4ab275f2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/optimize-knowledge-graph-embeddings-with-dgl-ke-1fff4ab275f2">Optimize Knowledge Graph Embeddings with DGL-KE</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Knowledge Graph Embedding with DGL-KE]]></title>
            <link>https://medium.com/data-science/introduction-to-knowledge-graph-embedding-with-dgl-ke-77ace6fb60ef?source=rss-ad11aea5ba40------2</link>
            <guid isPermaLink="false">https://medium.com/p/77ace6fb60ef</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[embedding]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Balaji Kamakoti]]></dc:creator>
            <pubDate>Mon, 15 Jun 2020 13:47:15 GMT</pubDate>
            <atom:updated>2020-06-17T17:00:10.571Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to Knowledge Graph Embeddings</h3><h4>Learn about Knowledge Graphs embeddings and two popular models to generate them with DGL-KE</h4><p>Author: Cyrus Vahid, Da Zheng, George Karypis and Balaji Kamakoti: AWS AI</p><p>Knowledge Graphs (KGs) have emerged as an effective way to integrate disparate data sources and model underlying relationships for applications such as search. At Amazon, <a href="https://www.amazon.science/blog/combining-knowledge-graphs-quickly-and-accurately">we use KGs</a> to represent the hierarchical relationships among products; the relationships between creators and content on Amazon Music and Prime Video; and information for Alexa’s question-answering service. Information extracted from KGs in the form of embeddings is used to improve search, recommend products, and infer missing information. It is however hard to train KG embeddings from graphs with millions of nodes and billions of edges.<br> <br> Amazon recently launched DGL-KE, a software package that simplifies this process with simple command-line scripts. With <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a>, users can generate embeddings for very large graphs 2–5x faster than competing techniques. DGL-KE provides users the flexibility to select models used to generate embeddings and optimize performance by configuring hardware, data sampling parameters, and the loss function. To use this package effectively, however, it is important to understand how embeddings work and the optimizations available to compute them. This two-part blog series is designed to provide this information and get you ready to start taking advantage of <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a>.</p><h3>What is a graph</h3><p>A graph is a structure used to represent things and their relations. It is made of two sets — the set of nodes (also called vertices) and the set of edges (also called arcs). Each edge itself connects a pair of nodes indicating that there is a relation between them. This relation can either be <em>undirected</em>, e.g., capturing symmetric relations between nodes, or <em>directed</em>, capturing asymmetric relations. For example, if a graph is used to model the friendship relations of people in a social network, then the edges will be undirected as they are used to indicate that two people are friends; however, if the graph is used to model how people follow each other on Twitter, the edges will be directed. Depending on the edges’ directionality, a graph can be <em>directed </em>or <em>undirected. </em><br> <br>Graphs can be either <em>homogeneous </em>or <em>heterogeneous</em>. In a homogeneous graph, all the nodes represent instances of the same type and all the edges represent relations of the same type. For instance, a social network is a graph consisting of people and their connections, all representing the same entity type. In contrast, in a heterogeneous graph, the nodes and edges can be of different types. For instance, the graph for encoding the information in a marketplace will have <em>buyer</em>, <em>seller</em>, and <em>product</em> nodes that are connected via <em>wants-to-buy</em>, <em>has-bought</em>, <em>is-customer-of</em>, and <em>is-selling</em> edges.<br> <br>Finally, another class of graphs that is especially important for knowledge graphs are <em>multigraphs</em>. These are graphs that can have multiple (directed) edges between the same pair of nodes and can also contain loops. These multiple edges are typically of different types and as such most multigraphs are heterogeneous. Note that graphs that do not allow these multiple edges and self-loops are called <em>simple</em> graphs.</p><h3>What is a knowledge graph</h3><p>In the earlier marketplace graph example, the labels assigned to the different node types (buyer, seller, product) and the different relation types (wants-to-buy, has-bought, is-customer-of, is-selling) convey precise information (often called <em>semantics</em>)<em> </em>about what the nodes and relations represent for that particular domain. Once this graph is populated, it will encode the knowledge that we have about that marketplace as it relates to types of nodes and relations included. Such a graph is an example of a knowledge graph.<br> <br>A knowledge graph (KG) is a directed heterogeneous multigraph whose node and relation types have domain-specific semantics. KGs allow us to encode the knowledge into a form that is human interpretable and amenable to automated analysis and inference. KGs are becoming a popular approach to represent diverse types of information in the form of different types of entities connected via different types of relations. <br> <br>When working with KGs, we adopt a different terminology than the traditional vertices and edges used in graphs. The vertices of the knowledge graph are often called <em>entities </em>and the directed edges are often called <em>triplets </em>and are represented as a (<em>h, r, t</em>) tuple, where <em>h </em>is the head entity, <em>t </em>is the tail entity, and <em>r </em>is the relation associating the head with the tail entities. Note that the term <em>relation</em> here refers to the type of the relation (e.g., one of wants-to-buy, has-bought, is-customer-of, and is-selling).<br> <br>Let’s now examine a KG with cast of a people and the world in which they live.</p><p><strong>Scenario:</strong><br><strong>Mary</strong> and <strong>Tom</strong> are <strong><em>siblings</em></strong> and they both are <strong><em>vegetarians</em></strong>, who <strong><em>like</em></strong> <strong>potatoes</strong> and <strong>cheese</strong>. Mary and Tom both <strong><em>work</em></strong> at <strong>Amazon</strong>. <strong>Joe</strong> is a bloke who is a <strong><em>colleague</em></strong> of Tom. To make matters complicated, Joe <strong><em>loves</em></strong> Mary, but we do not know if the feeling is reciprocated.</p><p>Joe <strong><em>is from</em></strong> <strong>Quebec</strong> and is proud of his native dish of <strong>Poutine</strong>, which is <strong><em>composed</em></strong> of potato, cheese, and <strong>gravy</strong>. We also know that gravy <strong><em>contains</em></strong> <strong>meat</strong> in some form.</p><p>Joe is excited to invite Tom for dinner and has sneakily included his sibling, Mary, in the invitation. His plans are doomed from the get-go as he is planning to serve the vegetarian siblings his favorite Quebecois dish, Poutine.</p><p>Oh! by the way, a piece of geography trivia: Quebec <strong><em>is located</em></strong> in a <strong>province</strong> of the same name which in turn <strong><em>is located</em></strong> in <strong>Canada</strong>.</p><p>There are several relationships in this scenario that are not explicitly mentioned but we can simply infer from what we are given:</p><ul><li>Mary is a colleague of Tom.</li><li>Tom is a colleague of Mary.</li><li>Mary is Tom’s sister.</li><li>Tom is Mary’s brother.</li><li>Poutine has meat.</li><li>Poutine is not a vegetarian dish.</li><li>Mary and Tom would not eat Poutine.</li><li>Poutine is a Canadian dish.</li><li>Joe is Canadian.</li><li>Amazon is a workplace for Mary, Tom, and Joe.</li></ul><p>Some interesting negative conclusions seem intuitive to us, but not to the machine:</p><ul><li>Potato <em>does not like</em> Mary.</li><li>Canada <em>is not from</em> Joe.</li><li>Canada <em>is not located</em> in Quebec.</li><li>…<br>What we have examined is a knowledge graph, a set of nodes with different types of relations:</li><li>1-to-1: Mary is a sibling of Tom.</li><li>1-to-N: Amazon is a workplace for Mary, Tom, and Joe.</li><li>N-to-1: Joe, Tom, and Mary work at Amazon.</li><li>N-to-N: Joe, Mary, and Tom are colleagues.</li></ul><p>There are other categorization perspectives on the relationships as well:</p><ul><li>Symmetric: Joe is a colleague of Tom entails Tom is also a colleague of Joe.</li><li>Antisymmetric: Quebec is located in Canada entails that Canada cannot be located in Quebec.</li></ul><p>Figure 1 visualizes a KG that describes the <em>World of Mary</em>. For more information on how to use the examples, please refer to the <a href="https://github.com/cyrusmvahid/GNNTrainingMaterial/tree/master/supporting_examples">code</a> embedded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*8sKQDJT0VXDtyOoKDJ8ExA.png" /></figure><h3>Knowledge graph embeddings</h3><p>Knowledge graph embeddings (KGEs) are low-dimensional representations of the entities and relations in a knowledge graph. They provide a generalizable context about the overall KG that can be used to infer relations. In the World of Mary visualized above, embeddings provide insights about relations among Mary, Joe, and Tom. In a larger and more dense KG, embeddings could provide insights about molecular property interactions to accelerate drug discovery or cluster user behaviors of scammers in a gaming network.<br> <br>The knowledge graph embeddings are computed so that they satisfy certain properties; i.e., they follow a given KGE <em>model. </em>These KGE models define different <em>score functions</em> that measure the distance of two entities relative to its relation type in the low-dimensional embedding space. These score functions are used to train the KGE models so that the entities connected by relations are close to each other while the entities that are not connected are far away.<br> <br>There are many popular KGE models such as <a href="https://papers.nips.cc/paper/5071-translating-embeddings-for-modeling-multi-relational-data.pdf">TransE</a>, <a href="https://www.aaai.org/ocs/index.php/AAAI/AAAI15/paper/viewPaper/9571">TransR</a>, <a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.383.2015&amp;rep=rep1&amp;type=pdf">RESCAL</a>, <a href="https://arxiv.org/abs/1412.6575">DistMult</a>, <a href="http://proceedings.mlr.press/v48/trouillon16.pdf">ComplEx</a>, and <a href="https://arxiv.org/pdf/1902.10197.pdf">RotatE</a>, which define different score functions to learn entity and relation embeddings. DGL-KE makes these implementations accessible with a simple input argument in the command line script. In this post, we introduce and compare TransE and TransR, two common methods to provide readers some intuition about the models and the tradeoffs<br> <br><strong>TransE</strong><br><a href="https://arxiv.org/pdf/1806.01973.pdf">Translation based embedding model (TransE)</a> is a representative translational distance model that represents entities and relations as vectors in the same semantic space of dimension Rd, where d is the dimension of the target space with reduced dimension. A fact in the source space is represented as a triplet (h,r,t) where h is short for the <em>head</em>, r is for the <em>relation</em>, and t is for the <em>tail</em>. The relationship is interpreted as a translation vector so that the embedded entities are connected by relation r have a short distance. [3, 4]</p><p>In terms of vector computation, it could mean adding a head to a relation should approximate to the relation’s tail or h+r ≈ t.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*Kz860_1DygvdEC8rYC3jFA.png" /></figure><p>TransE performs linear transformation and the scoring function is negative distance between:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*O9PgZY2Pjy9dHpsJUIheCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*U97Dzy42ZBLbWOX40rNedQ.png" /></figure><p><strong>TransR</strong></p><p>TransE cannot cover a relationship that is not 1-to-1 as it learns only one aspect of similarity. TransR addresses this issue with separating relationship space from entity space where h, t ∈ ℝᵏ and $r ∈ ℝᵈ. The semantic spaces do not need to be of the same dimension. In the multi-relationship modeling, we learn a projection matrix M∈ℝᵏˣᵈ for each relationship that can project an entity to different relationship semantic spaces. Each of these spaces captures a different aspect of an entity that is related to a distinct relationship. In this case, a head node, h, and tail node, t with a relationship r are projected into the relationship space using the learned projection matrix Mᵣ as hᵣ=hMᵣ and tᵣ=tM ᵣrespectively. Figure 4 illustrates this projection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*NWHx4UHEeMDhlwDRrHtcnw.png" /></figure><p>Let us explore this using an example. Mary and Tom are siblings and colleagues. They both are vegetarians. Joe also works for Amazon and is a colleague of Mary and Tom. TransE might end up learning very similar embeddings for Mary, Tom, and Joe because they are colleagues but cannot recognize the (not) sibling relationship. Using TransR, we learn projection matrices: M_sibling, M_colleague, and M_vegetarian that perform better at learning relationship like (not)sibling.<br> <br>The score function in TransR is similar to the one used in TransE and measures the euclidean distance between h+r and t, but the distance measure is per relationship space. More formally:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*8g2oEY5hEysa4VqDZ6JiAQ.png" /></figure><p>Another advantage of TransR over TransE is its ability to extract compositional rules. The ability to extract rules has two major benefits. It offers richer information and has a smaller memory space as we can infer some rules from others.<br> <br><strong>Tradeoffs</strong><br>The benefits from more expressive projections in TransR adds to the complexity of the model and a higher rate of data transfer, which has adversely affected distributed training. TransE requires O(<em>d</em>) parameters per relation, where dd is the dimension of semantic space in TransE and includes both entities and relationships. As TransR projects entities to a relationship space of dimension kk, it will require O(<em>kd</em>) parameters per relation. Depending on the size of k, this could potentially increase the number of parameters drastically. In exploring DGL-KE, we will examine the benefits of <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a> in making computation of knowledge embedding significantly more efficient. [5], [7]</p><p>For a detailed overview of other implementations in <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a>, please check out our documentation.</p><h3>What’s Next?</h3><p>In this blog post, we introduced the concept of Knowledge Graph embeddings (KGEs), how they work and two popular methods to generate KGEs. In our <a href="https://towardsdatascience.com/optimize-knowledge-graph-embeddings-with-dgl-ke-1fff4ab275f2?source=email-ad11aea5ba40-1592228879945-layerCake.autoLayerCakeWriterNotification-------------------------c241be34_5fc5_43b9_a2f1_4c0d47b32e26&amp;sk=c5e477feb73aba2119c44ea54d91bf47">next post</a>, we will explore how options available to accelerate training with <a href="https://github.com/awslabs/dgl-ke">DGL-KE</a>.</p><h3>References</h3><ol><li><a href="http://semantic-web-journal.net/system/files/swj1167.pdf">http://semantic-web-journal.net/system/files/swj1167.pdf</a></li><li>Zhiqing Sun, Zhi-Hong Deng, Jian-Yun Nie, and Jian Tang. RotatE: Knowledge graph embedding by relational rotation in complex space. CoRR, abs/1902.10197, 2019.</li><li>Knowledge Graph Embedding: A Survey of Approaches and Applications Quan Wang, Zhendong Mao, Bin Wang, and Li Guo. DOI 10.1109/TKDE.2017.2754499, IEEE Transactions on Knowledge and Data Engineering</li><li>transE: Antoine Bordes, Nicolas Usunier, Alberto Garcia-Duran, JasonWeston, and Oksana<br>Yakhnenko. Translating embeddings for modeling multi-relational data. In Advances in Neural Information Processing Systems 26. 2013.<br>5.TransR: Yankai Lin, Zhiyuan Liu, Maosong Sun, Yang Liu, and Xuan Zhu. Learning entity and relation embeddings for knowledge graph completion. In Proceedings of the Twenty-Ninth AAAI Conference on Artificial Intelligence, 2015.</li><li>RESCAL: Maximilian Nickel, Volker Tresp, and Hans-Peter Kriegel. A three-way model for collective learning on multi-relational data. In Proceedings of the 28th International Conference on International Conference on Machine Learning, ICML’11, 2011.</li><li>Survey paper: Q. Wang, Z. Mao, B. Wang and L. Guo, “Knowledge Graph Embedding: A Survey of Approaches and Applications,” in IEEE Transactions on Knowledge and Data Engineering, vol. 29, no. 12, pp. 2724–2743, 1 Dec. 2017.</li><li>DistMult: Bishan Yang, Scott Wen-tau Yih, Xiaodong He, Jianfeng Gao, and Li Deng. Embedding entities and relations for learning and inference in knowledge bases. In Proceedings of the International Conference on Learning Representations (ICLR)<br>2015, May 2015.</li><li>ComplEx: Théo Trouillon, Johannes Welbl, Sebastian Riedel, Éric Gaussier, and Guillaume Bouchard. Complex embeddings for simple link prediction. CoRR, abs/1606.06357, 2016.</li><li>Zhiqing Sun, Zhi-Hong Deng, Jian-Yun Nie, and Jian Tang. RotatE: Knowledge graph embedding by relational rotation in complex space. CoRR, abs/1902.10197, 2019.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77ace6fb60ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/introduction-to-knowledge-graph-embedding-with-dgl-ke-77ace6fb60ef">Introduction to Knowledge Graph Embedding with DGL-KE</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplify mixed precision training with MXNet-AMP]]></title>
            <link>https://medium.com/apache-mxnet/simplify-mixed-precision-training-with-mxnet-amp-dc2564b1c7b0?source=rss-ad11aea5ba40------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc2564b1c7b0</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mxnet]]></category>
            <category><![CDATA[nvidia]]></category>
            <dc:creator><![CDATA[Balaji Kamakoti]]></dc:creator>
            <pubDate>Thu, 17 Oct 2019 17:01:29 GMT</pubDate>
            <atom:updated>2019-10-18T21:00:27.547Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Written by: Przemek Tredak, Serge Panev, Dick Carter @ NVIDIA and Pedro Larroy, Thom Lane @ Amazon</em></p><p><em>And thanks to Joey Conway, Scot Junkin, Triston Cao, Davide Onofrio at NVIDIA; and Omar Orqueda, Anirudh Subramanian, Balaji Kamakoti at Amazon for their valuable feedback.</em></p><h3>Overview</h3><p>Training Deep Learning networks is a very computationally intensive task. Novel model architectures tend to have an increasing number of layers and parameters, which slows down training. Fortunately, new generations of hardware, such as NVIDIA’s Volta GPU, as well as software optimizations make training these latest models a feasible task. Designed specifically for deep learning, the first-generation Tensor Cores in Volta deliver groundbreaking performance with mixed-precision matrix multiply in FP16 and FP32 — up to 12X higher peak teraflops (TFLOPS) for training and 6X higher peak TFLOPS for inference over the prior-generation NVIDIA Pascal™[Figure 1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*sXhYVFJRYTpmDHLb2PW5CA.gif" /><figcaption>Figure 1. Tensor Cores in Volta</figcaption></figure><p>Many hardware and software optimization opportunities involve exploiting lower precision arithmetic, like using 16-bit floating point (FP16) instead of traditional 32-bit. For example, Tensor Cores available on new NVIDIA Volta and Turing GPUs operate on FP16 inputs in order to provide great speedup when performing convolutions or matrix multiply operations[Figure 2]. Not all operations should be performed in FP16 however, as the reduced dynamic range of this data format may result in overflows — as an example, the <strong>exp</strong> function should stay in full precision as even <strong>exp</strong>(11.1) results in overflow when computed in FP16. The appropriate mixing of full and lower precision operations results in a set of guidelines called <em>Mixed precision training</em> [3].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/0*2ozCWuuLXBrghV77" /><figcaption>Figure 2. Tensor core mixed precision accumulator</figcaption></figure><p>While training in FP16 showed great success in image classification tasks, other more complicated neural networks typically stayed in FP32 due to difficulties in manually applying the mixed precision training guidelines. That is where Automatic Mixed Precision (AMP) comes into play: It automatically applies the guidelines of mixed precision training, setting the appropriate data type for each operator.</p><p>In this blog we will show how to get started with mixed precision training using AMP in MXNet, considering by example the SSD network from GluonCV.</p><h3>Inside Automatic Mixed Precision</h3><p>There are 2 main features of AMP:</p><ul><li>Automatic casting of the model to mixed precision</li><li>Dynamic loss scaling via a provided set of utilities</li></ul><p>During the automatic casting phase, AMP searches the model for operations that are best suited to be performed in lower precision (like <strong>Conv</strong> or <strong>Dense</strong> layers), casting them to FP16 (shown in green in Figure [3] a). On the other hand, AMP also identifies the operations that have to stay in full precision (like <strong>Norm</strong> or <strong>exp</strong>) and forces them to stay in FP32 (shown in red in Figure [3] a). Then, it propagates the data types through the computation graph (Figure [3] b). Whenever an operator with multiple inputs is encountered (like addition or multiplication), AMP casts all of those inputs to the widest of their types (shown as the rightmost red graph node of Figure [3] c). For example, if an operator has both FP16 and FP32 inputs, all of them would be cast to FP32.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XPNJj8bcuMb8FFwk" /><figcaption>Figure 3. Automatic casting of the model. a) AMP first identifies nodes that should be cast to FP16 (green) and that must stay in FP32 (red). b) Then, it propagates the data types through the computation graph. c) Whenever there is a mismatch in data types of inputs to the operator, AMP casts those inputs to the widest type.</figcaption></figure><p>The reduced dynamic range [4] of FP16 with respect to FP32 might result in some gradients being too large (overflow) or too small (underflow) to be properly represented. Both of these situations can be alleviated by loss scaling — a technique that shifts the range of gradients up or down to keep them inside the dynamic range of FP16 (Figure [4]). In order to be the most effective for the wide range of different deep learning training tasks and networks, the loss scaling factor needs to be chosen dynamically, reacting to the change of gradient magnitude throughout the training. AMP provides the API to easily implement this dynamic loss scaling in the training script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XZmZoGRd0TVwTngo" /><figcaption>Figure 4. Effect of loss scaling on gradient distribution. Loss scaling ensures that the gradient values fit in the dynamic range of FP16.</figcaption></figure><h3>AMP in MXNet</h3><p>A typical training loop in MXNet Gluon looks like this:</p><pre>net = …</pre><pre>loss = …</pre><pre>trainer = mx.gluon.Trainer(…)</pre><pre>for data, label in data_iter:</pre><pre>    with mx.autograd.record():</pre><pre>        out = net(data)</pre><pre>        l = loss(out, label)</pre><pre>        mx.autograd.backward(l)</pre><pre>    trainer.step()</pre><p>To use AMP, only a few changes need to be made, as shown in bold:</p><pre><strong>from mxnet.contrib import amp</strong></pre><pre><strong>amp.init()</strong></pre><pre>net = …</pre><pre>loss = …</pre><pre>trainer = mx.gluon.Trainer(…)</pre><pre><strong>amp.init_trainer(trainer)</strong></pre><pre>for data, label in data_iter:</pre><pre>    with mx.autograd.record():</pre><pre>        out = net(data)</pre><pre>        l = loss(out, label)</pre><pre><strong>        with amp.scale_loss(l, trainer) as scaled_loss:</strong></pre><pre><strong>            mx.autograd.backward(scaled_loss)</strong></pre><pre>trainer.step()</pre><p>Let us see in turn what these additional lines do. First, we have:</p><pre><strong>from mxnet.contrib import amp</strong></pre><pre><strong>amp.init()</strong></pre><p>This part initializes AMP and changes the behavior of operators to realize the benefit from mixed precision. Next is:</p><pre><strong>amp.init_trainer(trainer)</strong></pre><p>This initializes Gluon Trainer to be used with the dynamic loss scaling built into AMP. And finally:</p><pre><strong>with amp.scale_loss(l, trainer) as scaled_loss:</strong></pre><pre><strong>    mx.autograd.backward(scaled_loss)</strong></pre><p>These 2 lines perform the dynamic loss scaling part of the mixed precision recipe and calculate the gradients with respect to the scaled loss. Note that the gradients obtained using this scaled version of the loss are also scaled by the same value. The gradients get unscaled inside the trainer.step() function, during the weight update phase. However, this behavior may be undesirable when training scripts perform gradient manipulation, like clipping, before the optimizer step. For use in these cases, AMP provides the amp.unscale(trainer) function, which directs AMP to perform the gradient unscaling earlier, before any such gradient manipulation can take place.</p><h3>AMP in practice</h3><h3>Single Shot Detector</h3><p>As a concrete example, we will look at how to accelerate the training of the detection model SSD (<a href="https://arxiv.org/pdf/1512.02325.pdf">Single Shot MultiBox Detector</a>, Liu et al. 2015)</p><p>For this experiment we will use an existing model and training script from the <a href="https://gluon-cv.mxnet.io/model_zoo/index.html">GluonCV model zoo</a>. The GPU used is a single V100 GPU 32GB, available for example in AWS P3DN instances.</p><p>First, let us check baseline training speed when using full precision.</p><pre>python train_ssd.py — dataset coco -j 4 — gpus 0 — network resnet50_v1 — data-shape 512</pre><pre>INFO:root:[Epoch 0][Batch 49], Speed: 58.105 samples/sec, CrossEntropy=1.190, SmoothL1=0.688</pre><pre>INFO:root:[Epoch 0][Batch 99], Speed: 58.683 samples/sec, CrossEntropy=0.693, SmoothL1=0.536</pre><pre>INFO:root:[Epoch 0][Batch 149], Speed: 58.915 samples/sec, CrossEntropy=0.500, SmoothL1=0.453</pre><pre>INFO:root:[Epoch 0][Batch 199], Speed: 58.422 samples/sec, CrossEntropy=0.396, SmoothL1=0.399</pre><p>The baseline perf is around 58 samples per second. Let us now perform the same experiment using AMP. The first step is to include AMP and initialize it:</p><pre>from mxnet.contrib import amp</pre><pre>amp.init()</pre><p>The next step is to create the trainer and initialize it with AMP for dynamic loss scaling. Currently, support for dynamic loss scaling is limited to trainers created with the update_on_kvstore=False option, so we add it to our trainer initialization:</p><pre>trainer = gluon.Trainer(net.collect_params(), ‘sgd’,</pre><pre>    {‘learning_rate’: args.lr, ‘wd’: args.wd, ‘momentum’: args.momentum},</pre><pre>    update_on_kvstore=False))</pre><pre>amp.init_trainer(trainer)</pre><p>The last modification is to add the actual dynamic loss scaling:</p><pre>with amp.scale_loss(sum_loss, trainer) as scaled_loss:</pre><pre>    autograd.backward(scaled_loss)</pre><p>That’s it. However, if you try running the script directly you may get the following error:</p><pre>mxnet.base.MXNetError: [21:49:01] src/operator/nn/convolution.cc:297: Check failed: (*in_type)[i] == dtype (0 vs. 2) : This layer requires uniform type. Expected ‘float16’ v.s. given ‘float32’ at ‘weight’</pre><p>This error occurs because the SSD script from GluonCV, before the actual training, launches the network once on the CPU context in order to obtain anchors for the data loader, and the CPU context does not support some of the FP16 operations, like <strong>Conv</strong> or <strong>Dense</strong> layers. We will fix this by changing the get_dataloader() function to use the GPU context for anchor generation:</p><pre>def get_dataloader(net, train_dataset, val_dataset, data_shape, batch_size, num_workers, ctx):</pre><pre>    […]</pre><pre>    net.collect_params().reset_ctx(ctx)</pre><pre>    with autograd.train_mode():</pre><pre>        _, _, anchors = net(mx.nd.zeros((1, 3, height, width), ctx))</pre><pre>        anchors = anchors.as_in_context(mx.cpu())</pre><p>We can now run this modified script and observe the speed improvement.</p><pre>python amp_train_ssd.py — dataset coco -j 4 — gpus 0 — network resnet50_v1 — data-shape 512</pre><pre>INFO:root:[Epoch 0][Batch 49], Speed: 93.585 samples/sec, CrossEntropy=1.166, SmoothL1=0.684</pre><pre>INFO:root:[Epoch 0][Batch 99], Speed: 93.773 samples/sec, CrossEntropy=0.682, SmoothL1=0.533</pre><pre>INFO:root:[Epoch 0][Batch 149], Speed: 93.399 samples/sec, CrossEntropy=0.493, SmoothL1=0.451</pre><pre>INFO:root:[Epoch 0][Batch 199], Speed: 93.674 samples/sec, CrossEntropy=0.391, SmoothL1=0.397</pre><p>Performance with AMP increases from the 58 samples per second baseline to 93 samples per second. This shows that by using MXNet-AMP and with only minor code additions, we obtain a 60% speed increase over the default FP32 script. You can compare the training with and without AMP with the <strong>— amp</strong> option in the training script.</p><h3>Mask-RCNN</h3><p>We can also add AMP to another deep learning task: instance segmentation. The most popular model is <a href="https://arxiv.org/pdf/1703.06870">Mask-RCNN</a> He et al. 2017, which can process 6 samples per second in the original implementation as shown in the training log below.</p><p>Let us look at the performance before AMP, on the AWS P3DN instance with one V100 32GB GPU:</p><pre>python train_mask_rcnn.py — dataset coco -j 4 — gpus 0</pre><pre>INFO:root:[Epoch 0][Batch 49], Speed: 4.749 samples/sec, RPN_Conf=0.402,RPN_SmoothL1=0.155,RCNN_CrossEntropy=10.085,RCNN_SmoothL1=2.458,RCNN_Mask=5.818,RPNAcc=0.863,RPNL1Loss=0.628,RCNNAcc=0.808,RCNNL1Loss=1.928,MaskAcc=0.547,MaskFGAcc=0.573</pre><pre>INFO:root:[Epoch 0][Batch 99], Speed: 5.951 samples/sec, RPN_Conf=0.335,RPN_SmoothL1=0.152,RCNN_CrossEntropy=8.767,RCNN_SmoothL1=2.508,RCNN_Mask=5.451,RPNAcc=0.877,RPNL1Loss=0.614,RCNNAcc=0.821,RCNNL1Loss=1.929,MaskAcc=0.588,MaskFGAcc=0.583</pre><pre>INFO:root:[Epoch 0][Batch 149], Speed: 5.916 samples/sec, RPN_Conf=0.310,RPN_SmoothL1=0.150,RCNN_CrossEntropy=8.174,RCNN_SmoothL1=2.534,RCNN_Mask=5.234,RPNAcc=0.881,RPNL1Loss=0.598,RCNNAcc=0.826,RCNNL1Loss=1.934,MaskAcc=0.615,MaskFGAcc=0.591</pre><pre>INFO:root:[Epoch 0][Batch 199], Speed: 5.825 samples/sec, RPN_Conf=0.296,RPN_SmoothL1=0.149,RCNN_CrossEntropy=7.885,RCNN_SmoothL1=2.555,RCNN_Mask=5.088,RPNAcc=0.884,RPNL1Loss=0.592,RCNNAcc=0.826,RCNNL1Loss=1.925,MaskAcc=0.633,MaskFGAcc=0.595</pre><p>Once again, there are three simple modifications:</p><pre>• Import AMP:</pre><pre>    from mxnet.contrib import amp</pre><pre>    amp.init()</pre><p>• Initialize the trainer with AMP:</p><pre>trainer = gluon.Trainer(net.collect_params(), ‘sgd’,</pre><pre>    {‘learning_rate’: args.lr, ‘wd’: args.wd, ‘momentum’: args.momentum},</pre><pre>    update_on_kvstore=False))</pre><pre>amp.init_trainer(trainer)</pre><p>• Perform loss scaling:</p><pre>with amp.scale_loss(losses, trainer) as scaled_losses:</pre><pre>    autograd.backward(scaled_losses)</pre><p>Let us take a look at the speed with AMP:</p><pre>python amp_train_mask_rcnn.py — dataset coco -j 4 — gpus 0</pre><pre>INFO:root:[Epoch 0][Batch 49], Speed: 9.043 samples/sec, RPN_Conf=0.449,RPN_SmoothL1=0.148,RCNN_CrossEntropy=12.762,RCNN_SmoothL1=2.483,RCNN_Mask=5.921,RPNAcc=0.842,RPNL1Loss=0.598,RCNNAcc=0.725,RCNNL1Loss=1.952,MaskAcc=0.542,MaskFGAcc=0.568</pre><pre>INFO:root:[Epoch 0][Batch 99], Speed: 9.779 samples/sec, RPN_Conf=0.360,RPN_SmoothL1=0.147,RCNN_CrossEntropy=9.857,RCNN_SmoothL1=2.512,RCNN_Mask=5.487,RPNAcc=0.867,RPNL1Loss=0.595,RCNNAcc=0.781,RCNNL1Loss=1.945,MaskAcc=0.585,MaskFGAcc=0.582</pre><pre>INFO:root:[Epoch 0][Batch 149], Speed: 10.281 samples/sec, RPN_Conf=0.328,RPN_SmoothL1=0.145,RCNN_CrossEntropy=8.883,RCNN_SmoothL1=2.558,RCNN_Mask=5.245,RPNAcc=0.874,RPNL1Loss=0.578,RCNNAcc=0.798,RCNNL1Loss=1.945,MaskAcc=0.614,MaskFGAcc=0.586</pre><pre>INFO:root:[Epoch 0][Batch 199], Speed: 9.603 samples/sec, RPN_Conf=0.309,RPN_SmoothL1=0.143,RCNN_CrossEntropy=8.290,RCNN_SmoothL1=2.576,RCNN_Mask=5.068,RPNAcc=0.879,RPNL1Loss=0.572,RCNNAcc=0.806,RCNNL1Loss=1.927,MaskAcc=0.636,MaskFGAcc=0.586</pre><p>By including AMP we are right around 10 samples per second. This gives us a 67% speed increase over the default FP32 version.</p><h3>Benchmarks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8uZFYr1t2AuCsiBD" /></figure><p>In our benchmarks with SSD and Faster RCNN models, AMP demonstrated ~2x improvement in the training throughput (samples/second) with a single GPU instance. In our preliminary Multi-GPU tests with Horovod, AMP improved training throughput of an SSD model by ~20%.</p><h3>References</h3><p>[1] “Use AMP (Automatic Mixed Precision) in MXNet” <a href="https://mxnet.apache.org/api/python/docs/tutorials/performance/backend/amp.html">https://mxnet.apache.org/api/python/docs/tutorials/performance/backend/amp.html</a></p><p>[2] “Automatic Mixed Precision for Deep Learning”, <a href="https://developer.nvidia.com/automatic-mixed-precision">https://developer.nvidia.com/automatic-mixed-precision</a></p><p>[3] “Single-precision floating-point format”, wikipedia, <a href="https://en.wikipedia.org/wiki/Single-precision_floating-point_format">https://en.wikipedia.org/wiki/Single-precision_floating-point_format</a></p><p>[4] “Training with Mixed Precision”, <a href="https://docs.nvidia.com/deeplearning/sdk/mixed-precision-training/index.html">https://docs.nvidia.com/deeplearning/sdk/mixed-precision-training/index.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc2564b1c7b0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/apache-mxnet/simplify-mixed-precision-training-with-mxnet-amp-dc2564b1c7b0">Simplify mixed precision training with MXNet-AMP</a> was originally published in <a href="https://medium.com/apache-mxnet">Apache MXNet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>