{"id":33797,"date":"2018-06-14T18:05:57","date_gmt":"2018-06-14T15:05:57","guid":{"rendered":"https:\/\/www.altoros.com\/blog\/?p=33797"},"modified":"2018-07-17T17:21:37","modified_gmt":"2018-07-17T14:21:37","slug":"three-approaches-to-testing-and-validating-tensorflow-models","status":"publish","type":"post","link":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/","title":{"rendered":"Three Approaches to Testing and Validating TensorFlow Code"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#The_rigors_of_testing\" >The rigors of testing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Assertion_techniques_to_consider\" >Assertion techniques to consider<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Approach_1_shape_assertions\" >Approach #1: shape assertions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Approach_2_the_TensorGroupDependency_package\" >Approach #2: the TensorGroupDependency package<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Approach_3_equation_assertions\" >Approach #3: equation assertions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Want_details_Watch_the_video\" >Want details? Watch the video!<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Related_slides\" >Related slides<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#Further_reading\" >Further reading<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#About_the_expert\" >About the expert<\/a><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"The_rigors_of_testing\"><\/span>The rigors of testing<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Validating TensorFlow code may pose certain difficulties. First, one needs to trample through the herds of tensor values, which are multi-dimensional arrays of data. In TensorFlow, computations are represented as dataflow graphs, and they are hardly an easy nut to crack. Using <a href=\"https:\/\/www.altoros.com\/blog\/visualizing-tensorflow-graphs-with-tensorboard\/\">TensorBoard<\/a> for graph visualization may give you the understanding of how neatly a graph is arranged. However, a single graph may have a hundred of nodes (units of computation) and edges (the data consumed\/produced by a computation).<\/p>\n<div id=\"attachment_33805\" style=\"width: 150px\" class=\"wp-caption alignright\"><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/yi-wei-debugging-tensorflow-code-v1.jpg\"><img decoding=\"async\" aria-describedby=\"caption-attachment-33805\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/yi-wei-debugging-tensorflow-code-v1.jpg\" alt=\"\" width=\"140\" class=\"size-full wp-image-33805\" \/><\/a><p id=\"caption-attachment-33805\" class=\"wp-caption-text\"><small>Yi Wei<\/small><\/p><\/div>\n<p>Employing general-purpose debuggers may not be an option due to the peculiarities of a nonlinear TensorFlow code structure. Anyway, you may need to provide specifications for a debugger what this or that piece of code is supposed to do, so the debugger can actually distinguish between the wrong and right.<\/p>\n<p>At the recent <a href=\"https:\/\/www.meetup.com\/ru-RU\/TensorFlow-London\/events\/250536941\/\" rel=\"noopener\" target=\"_blank\">TensorFlow meetup<\/a> in London, <a href=\"https:\/\/www.linkedin.com\/in\/yi-wei-72817516\/\" rel=\"noopener\" target=\"_blank\">Yi Wei<\/a> of Prowler shared a set of techniques he uses to write and debug TensorFlow code with no bloody efforts at stake.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Assertion_techniques_to_consider\"><\/span>Assertion techniques to consider<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Generally, <a href=\"https:\/\/en.wikipedia.org\/wiki\/Assertion_(software_development)\" rel=\"noopener\" target=\"_blank\">assertions<\/a> are used to determine that a predicate (a true-false expression) is always true at a given point in code execution. Providing assertions to the code enabled the system to evaluate the predicate, and if it is false, this may be a signal for a bug. This way, assertions help to check if a system operates as it is meant to.<\/p>\n<p>The set of assertion techniques developed by Yi to validate the correctness of TensorFlow code includes:<\/p>\n<ol>\n<li>tensor <i>shape assertions<\/i> to validate data shapes<\/li>\n<li>tensor <i>dependency assertions<\/i> to validate graph structure<\/li>\n<li>tensor <i>equation assertions<\/i> to validate numerical calculations<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Approach_1_shape_assertions\"><\/span>Approach #1: shape assertions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>To check the <b>shape<\/b> of the introduced tensor\u2014i.e., all the elements in each dimension\u2014you can write an assertion. In case a tensor shape is different to what you defined in the assertion, a violation will pop up.<\/p>\n<blockquote><p><em>&#8220;It sounds like a stupid child, but once you start writing those things, oh boy, you&#8217;ll realize how often you&#8217;re wrong about the assumptions of the shapes. And the <a href=\"https:\/\/www.tensorflow.org\/xla\/broadcasting\" rel=\"noopener\" target=\"_blank\">TensorFlow broadcasting<\/a> mechanism is just going to hide all these problems and pretend the code is going to work well.&#8221; \u2014Yi Wei, Prowler<\/em><\/p><\/blockquote>\n<p>You can make use of the assertion sample below.<\/p>\n<p><pre class=\"brush: python; title: ; notranslate\" title=\"\">prediction_tensor = q_function.output_tensor\r\nassert prediction_tensor.shape.to_list() == &#x5B;batch_size, action_dimension]\r\n\r\ntarget_tensor = reward_tensor + discount * bootstrapped_tensor\r\nassert target_tensor.shape.to_list() == &#x5B;batch_size, action_dimension]\r\n\r\nloss_tensor = tf.losses.mean_squared_error(target_tensor, prediction_tensor)\r\nassert loss_tensor.shape.to_list() == &#x5B;]<\/pre>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Approach_2_the_TensorGroupDependency_package\"><\/span>Approach #2: the TensorGroupDependency package<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Visualizing a graph via TensorBoard is all cool, still it comes at a price as the graph may have hundreds of nodes and edges, and you may not even know where to start from. So, how to verify <b>tensor dependencies<\/b> are exactly what they are supposed to be?<\/p>\n<p>Yi and his team developed the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TensorGroupDependency<\/code> package, written in Python. The package enables users to <i>group tensors into nodes<\/i>, <i>visualize only dependencies<\/i> of the introduced tensors, and automatically <i>generate graph structural assertions<\/i>.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/2.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/2-1024x576.png\" alt=\"\" width=\"640\" class=\"aligncenter size-large wp-image-33938\" \/><\/a><small>A visualization of the Generalized Advantage Estimation critic via <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TensorGroupDependency<\/code> (<a href=\"https:\/\/www.secondmind.ai\/\" rel=\"noopener\" target=\"_blank\">Image credit<\/a>)<\/small><\/center><\/p>\n<p>With the package, the graph also shows the shape of a tensor. This way, you get an overview of all the shapes, as well as their flow and transformations. Dependencies are represented as edges, and you must know for sure why each edge exists. If you can&#8217;t explain why there is an edge, it usually means a bug.<\/p>\n<blockquote><p><em>&#8220;Every edge exists, because you wired up the tensor graph like this. Does this wiring match what you think it should do?&#8221; \u2014Yi Wei, Prowler<\/em><\/p><\/blockquote>\n<p>As already mentioned, the package automatically generates assertions to describe the graph structure. By putting these assertions into your code, you enable automatic check of all the future executions.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/visualization-of-td-critic-method-with-TensorGroupDependency-tensorflow.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/visualization-of-td-critic-method-with-TensorGroupDependency-tensorflow-1024x576.png\" alt=\"\" width=\"640\" class=\"aligncenter size-large wp-image-33877\" \/><\/a><small>A visualization of the TD(\u03bb) critic method via <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TensorGroupDependency<\/code> (<a href=\"https:\/\/www.slideshare.net\/seldon_io\/tensorflow-london-15-find-bugs-in-the-herd-with-debuggable-tensorflow-code\">Image credit<\/a>)<\/small><\/center> <\/p>\n<p><code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TensorGroupDependency<\/code> is not generally available yet, but it is planned to open source the package soon.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Approach_3_equation_assertions\"><\/span>Approach #3: equation assertions<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Once you&#8217;re done with validating the correctness of tensor dependencies, you may want to verify these dependencies perform the <b>numerical calculations<\/b> appropriately. For the purpose, you need to proceed with tensor equation evaluations:<\/p>\n<ul>\n<li>add the tensors to <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">session.run<\/code> in each optimization step for each equation in your algorithm<\/li>\n<li>write the same equation in NumPY with the tensor evaluations<\/li>\n<li>make sure the expected value corresponds with that established in the algorithm definition<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Yi shared some results of applying the assertion techniques to the TensorFlow-based learning modules his team was developing. On writing the code behind the modules the team spent 24 hours. In the course of five hours, the team was able to detect 23 bugs in total.<\/p>\n<p><center><a href=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/summary-table-results-of-appying-assertion-techniques-to-tensorflow-based-modules.png\"><img decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/summary-table-results-of-appying-assertion-techniques-to-tensorflow-based-modules-1024x576.png\" alt=\"\" width=\"640\" class=\"aligncenter size-large wp-image-33893\" \/><\/a><small>A summary table of applying assertion techniques (<a href=\"https:\/\/www.slideshare.net\/seldon_io\/tensorflow-london-15-find-bugs-in-the-herd-with-debuggable-tensorflow-code\" rel=\"noopener\" target=\"_blank\">Image credit<\/a>)<\/small><\/center><\/p>\n<p>Yi wrote <a href=\"https:\/\/www.secondmind.ai\/\" rel=\"noopener\" target=\"_blank\">blog post<\/a> where he reveals more details about the results and the <code style=\"color: #222222; background-color: #e6e6e6; padding: 1px 2px;\">TensorGroupDependency<\/code> package, as well as provides sample code for the assertion techniques.<\/p>\n<p>The nonlinearity of TensorFlow code structure makes it difficult to use general-purpose debuggers. In addition to the suggested assertion methods, one can employ a <a href=\"https:\/\/www.tensorflow.org\/guide\" rel=\"noopener\" target=\"_blank\">native debugger<\/a> available through TensorFlow. Though, due to the continuous evolution of machine learning models, you may need to deviler customizations to complement the functionality of the TensorFlow debugger.<\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Want_details_Watch_the_video\"><\/span>Want details? Watch the video!<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><center><iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/aqqnZYa7v1E\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe><\/center><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Related_slides\"><\/span>Related slides<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p><center><iframe loading=\"lazy\" src=\"\/\/www.slideshare.net\/slideshow\/embed_code\/key\/t1aPzrJqNRPbzm\" width=\"595\" height=\"485\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" style=\"border:1px solid #CCC; border-width:1px; margin-bottom:5px; max-width: 100%;\" allowfullscreen><\/iframe><\/center><\/p>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Further_reading\"><\/span>Further reading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/visualizing-tensorflow-graphs-with-tensorboard\/\">Visualizing TensorFlow Graphs with TensorBoard<\/a><\/li>\n<li><a href=\"https:\/\/www.altoros.com\/blog\/logical-graphs-native-control-flow-operations-in-tensorflow\/\">Logical Graphs: Native Control Flow Operations in TensorFlow<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><span class=\"ez-toc-section\" id=\"About_the_expert\"><\/span>About the expert<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<div>\n<div style=\"float: right;\"><a href=\"https:\/\/www.linkedin.com\/in\/yi-wei-72817516\/\" rel=\"noopener\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/Yi-Wei-bio.png\" alt=\"\" width=\"150\" height=\"150\" class=\"alignright size-full wp-image-33818\" \/><\/a><\/div>\n<div style=\"width: 600px;\"><small><a href=\"https:\/\/www.linkedin.com\/in\/yi-wei-72817516\/\" rel=\"noopener\" target=\"_blank\">Yi Wei<\/a> is a senior machine learning engineer at Prowler. He focuses on deep reinforcement learning algorithms for automated trading. Prior to Prowler, Yi was a co-founder of the CTX Fintech company, which provides algorithmic trading infrastructure. He also worked at Microsoft Research Cambridge for three years. Yi participated in developing the code snippets technology that synthesizes code from user natural language queries and publicly available code repositories. He won the Microsoft Research Technology Transfer Award for the CodeSnippets project. Yi Wei got his PhD in automated testing and bug fixing from ETH Zurich in 2012.<\/small><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The rigors of testing<\/p>\n<p>Validating TensorFlow code may pose certain difficulties. First, one needs to trample through the herds of tensor values, which are multi-dimensional arrays of data. In TensorFlow, computations are represented as dataflow graphs, and they are hardly an easy nut to crack. Using TensorBoard for graph visualization may [&#8230;]<\/p>\n","protected":false},"author":3,"featured_media":33954,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"content-type":"","footnotes":"","_links_to":"","_links_to_target":""},"categories":[214],"tags":[748,749],"class_list":["post-33797","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-machine-learning","tag-tensorflow"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Three Approaches to Testing and Validating TensorFlow Code | Altoros<\/title>\n<meta name=\"description\" content=\"Read about some assertion methods that may help to validate data shapes, graph structures, and numerical calculations of the TensorFlow code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Three Approaches to Testing and Validating TensorFlow Code | Altoros\" \/>\n<meta property=\"og:description\" content=\"The rigors of testing Validating TensorFlow code may pose certain difficulties. First, one needs to trample through the herds of tensor values, which are multi-dimensional arrays of data. In TensorFlow, computations are represented as dataflow graphs, and they are hardly an easy nut to crack. Using TensorBoard for graph visualization may [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/\" \/>\n<meta property=\"og:site_name\" content=\"Altoros\" \/>\n<meta property=\"article:published_time\" content=\"2018-06-14T15:05:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-07-17T14:21:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"360\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/gif\" \/>\n<meta name=\"author\" content=\"Sophia Turol\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sophia Turol\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/\",\"name\":\"Three Approaches to Testing and Validating TensorFlow Code | Altoros\",\"isPartOf\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif\",\"datePublished\":\"2018-06-14T15:05:57+00:00\",\"dateModified\":\"2018-07-17T14:21:37+00:00\",\"author\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/58194952af19fe7b2b830846e077a58e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif\",\"width\":640,\"height\":360},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.altoros.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Three Approaches to Testing and Validating TensorFlow Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#website\",\"url\":\"https:\/\/www.altoros.com\/blog\/\",\"name\":\"Altoros\",\"description\":\"Insight\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.altoros.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/58194952af19fe7b2b830846e077a58e\",\"name\":\"Sophia Turol\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/05\/trello_card-96x96.jpg\",\"contentUrl\":\"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/05\/trello_card-96x96.jpg\",\"caption\":\"Sophia Turol\"},\"description\":\"Sophia Turol is passionate about delivering well-structured articles that cater for picky technical audience. With 3+ years in technical writing and 5+ years in editorship, she enjoys collaboration with developers to create insightful, yet intelligible technical tutorials, overviews, and case studies. Sophie is enthusiastic about deep learning solutions\u2014TensorFlow in particular\u2014and PaaS systems, such as Cloud Foundry.\",\"url\":\"https:\/\/www.altoros.com\/blog\/author\/sophie-turol\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Three Approaches to Testing and Validating TensorFlow Code | Altoros","description":"Read about some assertion methods that may help to validate data shapes, graph structures, and numerical calculations of the TensorFlow code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/","og_locale":"en_US","og_type":"article","og_title":"Three Approaches to Testing and Validating TensorFlow Code | Altoros","og_description":"The rigors of testing Validating TensorFlow code may pose certain difficulties. First, one needs to trample through the herds of tensor values, which are multi-dimensional arrays of data. In TensorFlow, computations are represented as dataflow graphs, and they are hardly an easy nut to crack. Using TensorBoard for graph visualization may [...]","og_url":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/","og_site_name":"Altoros","article_published_time":"2018-06-14T15:05:57+00:00","article_modified_time":"2018-07-17T14:21:37+00:00","og_image":[{"width":640,"height":360,"url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif","type":"image\/gif"}],"author":"Sophia Turol","twitter_misc":{"Written by":"Sophia Turol","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/","url":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/","name":"Three Approaches to Testing and Validating TensorFlow Code | Altoros","isPartOf":{"@id":"https:\/\/www.altoros.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage"},"image":{"@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage"},"thumbnailUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif","datePublished":"2018-06-14T15:05:57+00:00","dateModified":"2018-07-17T14:21:37+00:00","author":{"@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/58194952af19fe7b2b830846e077a58e"},"breadcrumb":{"@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#primaryimage","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2018\/06\/assertion-techniques-to-validate-and-debug-tensorflow-models-v1.gif","width":640,"height":360},{"@type":"BreadcrumbList","@id":"https:\/\/www.altoros.com\/blog\/three-approaches-to-testing-and-validating-tensorflow-models\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.altoros.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Three Approaches to Testing and Validating TensorFlow Code"}]},{"@type":"WebSite","@id":"https:\/\/www.altoros.com\/blog\/#website","url":"https:\/\/www.altoros.com\/blog\/","name":"Altoros","description":"Insight","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.altoros.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/58194952af19fe7b2b830846e077a58e","name":"Sophia Turol","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.altoros.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/05\/trello_card-96x96.jpg","contentUrl":"https:\/\/www.altoros.com\/blog\/wp-content\/uploads\/2019\/05\/trello_card-96x96.jpg","caption":"Sophia Turol"},"description":"Sophia Turol is passionate about delivering well-structured articles that cater for picky technical audience. With 3+ years in technical writing and 5+ years in editorship, she enjoys collaboration with developers to create insightful, yet intelligible technical tutorials, overviews, and case studies. Sophie is enthusiastic about deep learning solutions\u2014TensorFlow in particular\u2014and PaaS systems, such as Cloud Foundry.","url":"https:\/\/www.altoros.com\/blog\/author\/sophie-turol\/"}]}},"_links":{"self":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/33797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/comments?post=33797"}],"version-history":[{"count":50,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/33797\/revisions"}],"predecessor-version":[{"id":34711,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/posts\/33797\/revisions\/34711"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media\/33954"}],"wp:attachment":[{"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/media?parent=33797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/categories?post=33797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.altoros.com\/blog\/wp-json\/wp\/v2\/tags?post=33797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}