{"id":6172,"date":"2026-04-22T23:29:40","date_gmt":"2026-04-22T23:29:40","guid":{"rendered":"https:\/\/profitiraj.ba\/what-they-are-and-how-to-use-them\/"},"modified":"2026-04-22T23:29:40","modified_gmt":"2026-04-22T23:29:40","slug":"what-theyre-and-tips-on-how-to-use-them","status":"publish","type":"post","link":"https:\/\/profitiraj.ba\/bs\/what-theyre-and-tips-on-how-to-use-them\/","title":{"rendered":"What they&#8217;re and tips on how to use them"},"content":{"rendered":"<div class=\"af1ed52b2bea0830e8f3a5b7a892ea1d\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<div data-type=\"_mgwidget\" data-widget-id=\"2030988\">\r\n<\/div>\r\n<script>(function(w,q){w[q]=w[q]||[];w[q].push([\"_mgc.load\"])})(window,\"_mgq\");\r\n<\/script>\n<\/div>\n<p><img decoding=\"async\" src=\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\" \/><\/p>\n<div>\n<p>Knowledge pre-processing: What you do to the info earlier than feeding it to the mannequin.<br \/>\u2014 A easy definition that, in apply, leaves open many questions. The place, precisely, ought to pre-processing cease, and the mannequin start? Are steps like normalization, or numerous numerical transforms, a part of the mannequin, or the pre-processing? What about information augmentation? In sum, the road between what&#8217;s pre-processing and what&#8217;s modeling has at all times, on the edges, felt considerably fluid.<\/p>\n<p>On this state of affairs, the appearance of <code>keras<\/code> pre-processing layers adjustments a long-familiar image.<\/p>\n<p>In concrete phrases, with <code>keras<\/code>two alternate options tended to prevail: one, to do issues upfront, in R; and two, to assemble a <code>tfdatasets<\/code> pipeline. The previous utilized every time we would have liked the entire information to extract some abstract info. For instance, when normalizing to a imply of zero and a typical deviation of 1. However typically, this meant that we needed to remodel back-and-forth between normalized and un-normalized variations at a number of factors within the workflow. The <code>tfdatasets<\/code> strategy, then again, was elegant; nevertheless, it may require one to jot down lots of low-level <code>tensorflow<\/code> code.<\/p>\n<p>Pre-processing layers, accessible as of <code>keras<\/code> model 2.6.1, take away the necessity for upfront R operations, and combine properly with <code>tfdatasets<\/code>. However that&#8217;s not all there may be to them. On this publish, we wish to spotlight 4 important features:<\/p>\n<ol type=\"1\">\n<li>Pre-processing layers considerably scale back coding effort. You <em>may<\/em> code these operations your self; however not having to take action saves time, favors modular code, and helps to keep away from errors.<\/li>\n<li>Pre-processing layers \u2013 a subset of them, to be exact \u2013 can produce abstract info earlier than coaching correct, and make use of a saved state when known as upon later.<\/li>\n<li>Pre-processing layers can pace up coaching.<\/li>\n<li>Pre-processing layers are, or may be made, a part of the mannequin, thus eradicating the necessity to implement unbiased pre-processing procedures within the deployment surroundings.<\/li>\n<\/ol>\n<p>Following a brief introduction, we\u2019ll increase on every of these factors. We conclude with two end-to-end examples (involving photographs and textual content, respectively) that properly illustrate these 4 features.<\/p>\n<h2 id=\"pre-processing-layers-in-a-nutshell\">Pre-processing layers in a nutshell<\/h2>\n<p>Like different <code>keras<\/code> layers, those we\u2019re speaking about right here all begin with <code>layer_<\/code>and could also be instantiated independently of mannequin and information pipeline. Right here, we create a layer that can randomly rotate photographs whereas coaching, by as much as 45 levels in each instructions:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">keras<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">aug_layer<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_random_rotation<\/span><span class=\"op\">(<\/span>issue <span class=\"op\">=<\/span> <span class=\"fl\">0.125<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>As soon as we&#8217;ve got such a layer, we will instantly check it on some dummy picture.<\/p>\n<pre><code>tf.Tensor(\n[[1. 0. 0. 0. 0.]\n [0. 1. 0. 0. 0.]\n [0. 0. 1. 0. 0.]\n [0. 0. 0. 1. 0.]\n [0. 0. 0. 0. 1.]], form=(5, 5), dtype=float32)<\/code><\/pre>\n<p>\u201cTesting the layer\u201d now actually means <em>calling it like a perform<\/em>:<\/p>\n<pre><code>tf.Tensor(\n[[0.         0.         0.         0.         0.        ]\n [0.44459596 0.32453176 0.05410459 0.         0.        ]\n [0.15844001 0.4371609  1.         0.4371609  0.15844001]\n [0.         0.         0.05410453 0.3245318  0.44459593]\n [0.         0.         0.         0.         0.        ]], form=(5, 5), dtype=float32)<\/code><\/pre>\n<p>As soon as instantiated, a layer can be utilized in two methods. Firstly, as a part of the enter pipeline.<\/p>\n<p>In pseudocode:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"co\"># pseudocode<\/span><\/span>\n<span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">tfdatasets<\/span><span class=\"op\">)<\/span><\/span>\n<span> <\/span>\n<span><span class=\"va\">train_ds<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">...<\/span> <span class=\"co\"># outline dataset<\/span><\/span>\n<span><span class=\"va\">preprocessing_layer<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">...<\/span> <span class=\"co\"># instantiate layer<\/span><\/span>\n<span\/>\n<span><span class=\"va\">train_ds<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">train_ds<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_map<\/span><span class=\"op\">(<\/span><span class=\"kw\">perform<\/span><span class=\"op\">(<\/span><span class=\"va\">x<\/span>, <span class=\"va\">y<\/span><span class=\"op\">)<\/span> <span class=\"fu\">checklist<\/span><span class=\"op\">(<\/span><span class=\"fu\">preprocessing_layer<\/span><span class=\"op\">(<\/span><span class=\"va\">x<\/span><span class=\"op\">)<\/span>, <span class=\"va\">y<\/span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>Secondly, the way in which that appears most pure, for a <em>layer<\/em>: as a layer contained in the mannequin. Schematically:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"co\"># pseudocode<\/span><\/span>\n<span><span class=\"va\">enter<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_input<\/span><span class=\"op\">(<\/span>form <span class=\"op\">=<\/span> <span class=\"va\">input_shape<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">enter<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">preprocessing_layer<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">rest_of_the_model<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">mannequin<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">keras_model<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span>, <span class=\"va\">output<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>In reality, the latter appears so apparent that you just is perhaps questioning: Why even enable for a <code>tfdatasets<\/code>-integrated various? We\u2019ll increase on that shortly, when speaking about efficiency.<\/p>\n<p><em>Stateful<\/em> layers \u2013 who&#8217;re particular sufficient to deserve their very own part \u2013 can be utilized in each methods as nicely, however they require a further step. Extra on that under.<\/p>\n<h2 id=\"how-pre-processing-layers-make-life-easier\">How pre-processing layers make life simpler<\/h2>\n<p>Devoted layers exist for a large number of data-transformation duties. We are able to subsume them underneath two broad classes, function engineering and information augmentation.<\/p>\n<h5 id=\"feature-engineering\">Characteristic engineering<\/h5>\n<p>The necessity for function engineering could come up with all varieties of information. With photographs, we don\u2019t usually use that time period for the \u201cpedestrian\u201d operations which are required for a mannequin to course of them: resizing, cropping, and such. Nonetheless, there are assumptions hidden in every of those operations , so we really feel justified in our categorization. Be that as it might, layers on this group embody <code>layer_resizing()<\/code>, <code>layer_rescaling()<\/code>and <code>layer_center_crop()<\/code>.<\/p>\n<p>With textual content, the one performance we couldn\u2019t do with out is vectorization. <code>layer_text_vectorization()<\/code> takes care of this for us. We\u2019ll encounter this layer within the subsequent part, in addition to within the second full-code instance.<\/p>\n<p>Now, on to what&#8217;s usually seen as <em>the<\/em> area of function engineering: numerical and categorical (we would say: \u201cspreadsheet\u201d) information.<\/p>\n<p>First, numerical information typically have to be normalized for neural networks to carry out nicely \u2013 to realize this, use <code>layer_normalization()<\/code>. Or possibly there&#8217;s a purpose we\u2019d wish to put steady values into discrete classes. That\u2019d be a process for <code>layer_discretization()<\/code>.<\/p>\n<p>Second, categorical information are available in numerous codecs (strings, integers \u2026), and there\u2019s at all times <em>one thing<\/em> that must be finished to be able to course of them in a significant means. Typically, you\u2019ll wish to embed them right into a higher-dimensional house, utilizing <code>layer_embedding()<\/code>. Now, embedding layers count on their inputs to be integers; to be exact: consecutive integers. Right here, the layers to search for are <code>layer_integer_lookup()<\/code> and <code>layer_string_lookup()<\/code>: They are going to convert random integers (strings, respectively) to consecutive integer values. In a distinct state of affairs, there is perhaps too many classes to permit for helpful info extraction. In such instances, use <code>layer_hashing()<\/code> to bin the info. And at last, there\u2019s <code>layer_category_encoding()<\/code> to provide the classical one-hot or multi-hot representations.<\/p>\n<h5 id=\"data-augmentation\">Knowledge augmentation<\/h5>\n<p>Within the second class, we discover layers that execute <span class=\"math display\">[configurable]<\/span>  random operations on photographs. To call just some of them: <code>layer_random_crop()<\/code>, <code>layer_random_translation()<\/code>, <code>layer_random_rotation()<\/code> \u2026 These are handy not simply in that they implement the required low-level performance; when built-in right into a mannequin, they\u2019re additionally workflow-aware: Any random operations will probably be executed throughout coaching solely.<\/p>\n<p>Now we&#8217;ve got an concept what these layers do for us, let\u2019s deal with the precise case of state-preserving layers.<\/p>\n<h2 id=\"pre-processing-layers-that-keep-state\">Pre-processing layers that preserve state<\/h2>\n<p>A layer that randomly perturbs photographs doesn\u2019t must know something concerning the information. It simply must comply with a rule: With likelihood <span class=\"math inline\">(p)<\/span>do <span class=\"math inline\">(x)<\/span>. A layer that\u2019s alleged to vectorize textual content, then again, must have a lookup desk, matching character strings to integers. The identical goes for a layer that maps contingent integers to an ordered set. And in each instances, the lookup desk must be constructed upfront.<\/p>\n<p>With stateful layers, this information-buildup is triggered by calling <code>adapt()<\/code> on a freshly-created layer occasion. For instance, right here we instantiate and \u201csituation\u201d a layer that maps strings to consecutive integers:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"va\">colours<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"st\">\"cyan\"<\/span>, <span class=\"st\">\"turquoise\"<\/span>, <span class=\"st\">\"celeste\"<\/span><span class=\"op\">)<\/span>;<\/span>\n<span\/>\n<span><span class=\"va\">layer<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_string_lookup<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">layer<\/span> <span class=\"op\">%&gt;%<\/span> <span class=\"fu\">adapt<\/span><span class=\"op\">(<\/span><span class=\"va\">colours<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>We are able to test what\u2019s within the lookup desk:<\/p>\n<pre><code>[1] \"[UNK]\"     \"turquoise\" \"cyan\"      \"celeste\"  <\/code><\/pre>\n<p>Then, calling the layer will encode the arguments:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"fu\">layer<\/span><span class=\"op\">(<\/span><span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"st\">\"azure\"<\/span>, <span class=\"st\">\"cyan\"<\/span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<pre><code>tf.Tensor([0 2], form=(2,), dtype=int64)<\/code><\/pre>\n<p><code>layer_string_lookup()<\/code>  works on particular person character strings, and consequently, is the transformation enough for string-valued categorical options. To encode entire sentences (or paragraphs, or any chunks of textual content) you\u2019d use <code>layer_text_vectorization()<\/code> as a substitute. We\u2019ll see how that works in our second end-to-end instance.<\/p>\n<h2 id=\"using-pre-processing-layers-for-performance\">Utilizing pre-processing layers for efficiency<\/h2>\n<p>Above, we stated that pre-processing layers could possibly be utilized in two methods: as a part of the mannequin, or as a part of the info enter pipeline. If these are <em>layers<\/em>why even enable for the second means?<\/p>\n<p>The principle purpose is efficiency. GPUs are nice at common matrix operations, similar to these concerned in picture manipulation and transformations of uniformly-shaped numerical information. Due to this fact, you probably have a GPU to coach on, it&#8217;s preferable to have picture processing layers, or layers similar to <code>layer_normalization()<\/code>be a part of the mannequin (which is run fully on GPU).<\/p>\n<p>Then again, operations involving textual content, similar to <code>layer_text_vectorization()<\/code>are greatest executed on the CPU. The identical holds if no GPU is obtainable for coaching. In these instances, you&#8217;d transfer the layers to the enter pipeline, and try to learn from parallel \u2013 on-CPU \u2013 processing. For instance:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"co\"># pseudocode<\/span><\/span>\n<span\/>\n<span><span class=\"va\">preprocessing_layer<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">...<\/span> <span class=\"co\"># instantiate layer<\/span><\/span>\n<span\/>\n<span><span class=\"va\">dataset<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">dataset<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_map<\/span><span class=\"op\">(<\/span><span class=\"op\">~<\/span><span class=\"fu\">checklist<\/span><span class=\"op\">(<\/span><span class=\"fu\">text_vectorizer<\/span><span class=\"op\">(<\/span><span class=\"va\">.x<\/span><span class=\"op\">)<\/span>, <span class=\"va\">.y<\/span><span class=\"op\">)<\/span>,<\/span>\n<span>              num_parallel_calls <span class=\"op\">=<\/span> <span class=\"va\">tf<\/span><span class=\"op\">$<\/span><span class=\"va\">information<\/span><span class=\"op\">$<\/span><span class=\"va\">AUTOTUNE<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_prefetch<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">mannequin<\/span> <span class=\"op\">%&gt;%<\/span> <span class=\"fu\">match<\/span><span class=\"op\">(<\/span><span class=\"va\">dataset<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>Accordingly, within the end-to-end examples under, you\u2019ll see picture information augmentation taking place as a part of the mannequin, and textual content vectorization, as a part of the enter pipeline.<\/p>\n<h2 id=\"exporting-a-model-complete-with-pre-processing\">Exporting a mannequin, full with pre-processing<\/h2>\n<p>Say that for coaching your mannequin, you discovered that the <code>tfdatasets<\/code> means was one of the best. Now, you deploy it to a server that doesn&#8217;t have R put in. It will seem to be that both, it&#8217;s important to implement pre-processing in another, accessible, expertise. Alternatively, you\u2019d need to depend on customers sending already-pre-processed information.<\/p>\n<p>Thankfully, there&#8217;s something else you are able to do. Create a brand new mannequin particularly for inference, like so:<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"co\"># pseudocode<\/span><\/span>\n<span\/>\n<span><span class=\"va\">enter<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_input<\/span><span class=\"op\">(<\/span>form <span class=\"op\">=<\/span> <span class=\"va\">input_shape<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">enter<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">preprocessing_layer<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">training_model<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">inference_model<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">keras_model<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span>, <span class=\"va\">output<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<p>This system makes use of the practical API to create a brand new mannequin that prepends the pre-processing layer to the pre-processing-less, unique mannequin.<\/p>\n<p>Having centered on a number of issues particularly \u201cgood to know\u201d, we now conclude with the promised examples.<\/p>\n<h2 id=\"example-1-image-data-augmentation\">Instance 1: Picture information augmentation<\/h2>\n<p>Our first instance demonstrates picture information augmentation. Three varieties of transformations are grouped collectively, making them stand out clearly within the total mannequin definition. This group of layers will probably be energetic throughout coaching solely.<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">keras<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">tfdatasets<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Load CIFAR-10 information that include keras<\/span><\/span>\n<span><span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"va\">x_train<\/span>, <span class=\"va\">y_train<\/span><span class=\"op\">)<\/span>, <span class=\"va\">...<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&lt;-%<\/span> <span class=\"fu\">dataset_cifar10<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">input_shape<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">dim<\/span><span class=\"op\">(<\/span><span class=\"va\">x_train<\/span><span class=\"op\">)<\/span><span class=\"op\">[<\/span><span class=\"op\">-<\/span><span class=\"fl\">1<\/span><span class=\"op\">]<\/span> <span class=\"co\"># drop batch dim<\/span><\/span>\n<span><span class=\"va\">courses<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fl\">10<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Create a tf_dataset pipeline <\/span><\/span>\n<span><span class=\"va\">train_dataset<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">tensor_slices_dataset<\/span><span class=\"op\">(<\/span><span class=\"fu\">checklist<\/span><span class=\"op\">(<\/span><span class=\"va\">x_train<\/span>, <span class=\"va\">y_train<\/span><span class=\"op\">)<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_batch<\/span><span class=\"op\">(<\/span><span class=\"fl\">16<\/span><span class=\"op\">)<\/span> <\/span>\n<span\/>\n<span><span class=\"co\"># Use a (non-trained) ResNet structure<\/span><\/span>\n<span><span class=\"va\">resnet<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">application_resnet50<\/span><span class=\"op\">(<\/span>weights <span class=\"op\">=<\/span> <span class=\"cn\">NULL<\/span>,<\/span>\n<span>                               input_shape <span class=\"op\">=<\/span> <span class=\"va\">input_shape<\/span>,<\/span>\n<span>                               courses <span class=\"op\">=<\/span> <span class=\"va\">courses<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Create a knowledge augmentation stage with horizontal flipping, rotations, zooms<\/span><\/span>\n<span><span class=\"va\">data_augmentation<\/span> <span class=\"op\">&lt;-<\/span><\/span>\n<span>  <span class=\"fu\">keras_model_sequential<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_random_flip<\/span><span class=\"op\">(<\/span><span class=\"st\">\"horizontal\"<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_random_rotation<\/span><span class=\"op\">(<\/span><span class=\"fl\">0.1<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_random_zoom<\/span><span class=\"op\">(<\/span><span class=\"fl\">0.1<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">enter<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_input<\/span><span class=\"op\">(<\/span>form <span class=\"op\">=<\/span> <span class=\"va\">input_shape<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Outline and run the mannequin<\/span><\/span>\n<span><span class=\"va\">output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">enter<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_rescaling<\/span><span class=\"op\">(<\/span><span class=\"fl\">1<\/span> <span class=\"op\">\/<\/span> <span class=\"fl\">255<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span>   <span class=\"co\"># rescale inputs<\/span><\/span>\n<span>  <span class=\"fu\">data_augmentation<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">resnet<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">mannequin<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">keras_model<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span>, <span class=\"va\">output<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">compile<\/span><span class=\"op\">(<\/span>optimizer <span class=\"op\">=<\/span> <span class=\"st\">\"rmsprop\"<\/span>, loss <span class=\"op\">=<\/span> <span class=\"st\">\"sparse_categorical_crossentropy\"<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">match<\/span><span class=\"op\">(<\/span><span class=\"va\">train_dataset<\/span>, steps_per_epoch <span class=\"op\">=<\/span> <span class=\"fl\">5<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<h2 id=\"example-2-text-vectorization\">Instance 2: Textual content vectorization<\/h2>\n<p>In pure language processing, we regularly use embedding layers to current the \u201cworkhorse\u201d (recurrent, convolutional, self-attentional, what have you ever) layers with the continual, optimally-dimensioned enter they want. Embedding layers count on tokens to be encoded as integers, and remodel textual content to integers is what <code>layer_text_vectorization()<\/code> does.<\/p>\n<p>Our second instance demonstrates the workflow: You may have the layer be taught the vocabulary upfront, then name it as a part of the pre-processing pipeline. As soon as coaching has completed, we create an \u201call-inclusive\u201d mannequin for deployment.<\/p>\n<div class=\"layout-chunk\" data-layout=\"l-body\">\n<div class=\"sourceCode\">\n<pre class=\"sourceCode r\"><code class=\"sourceCode r\"><span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">tensorflow<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">tfdatasets<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"kw\">library<\/span><span class=\"op\">(<\/span><span class=\"va\">keras<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Instance information<\/span><\/span>\n<span><span class=\"va\">textual content<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">as_tensor<\/span><span class=\"op\">(<\/span><span class=\"fu\">c<\/span><span class=\"op\">(<\/span><\/span>\n<span>  <span class=\"st\">\"From every in keeping with his means, to every in keeping with his wants!\"<\/span>,<\/span>\n<span>  <span class=\"st\">\"Act that you just use humanity, whether or not in your individual particular person or within the particular person of another, at all times concurrently an finish, by no means merely as a method.\"<\/span>,<\/span>\n<span>  <span class=\"st\">\"Cause is, and ought solely to be the slave of the passions, and might by no means fake to another workplace than to serve and obey them.\"<\/span><\/span>\n<span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Create and adapt layer<\/span><\/span>\n<span><span class=\"va\">text_vectorizer<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_text_vectorization<\/span><span class=\"op\">(<\/span>output_mode<span class=\"op\">=<\/span><span class=\"st\">\"int\"<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">text_vectorizer<\/span> <span class=\"op\">%&gt;%<\/span> <span class=\"fu\">adapt<\/span><span class=\"op\">(<\/span><span class=\"va\">textual content<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Test<\/span><\/span>\n<span><span class=\"fu\">as.array<\/span><span class=\"op\">(<\/span><span class=\"fu\">text_vectorizer<\/span><span class=\"op\">(<\/span><span class=\"st\">\"To every in keeping with his wants\"<\/span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Create a easy classification mannequin<\/span><\/span>\n<span><span class=\"va\">enter<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_input<\/span><span class=\"op\">(<\/span><span class=\"fu\">form<\/span><span class=\"op\">(<\/span><span class=\"cn\">NULL<\/span><span class=\"op\">)<\/span>, dtype<span class=\"op\">=<\/span><span class=\"st\">\"int64\"<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">enter<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_embedding<\/span><span class=\"op\">(<\/span>input_dim <span class=\"op\">=<\/span> <span class=\"va\">text_vectorizer<\/span><span class=\"op\">$<\/span><span class=\"fu\">vocabulary_size<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span>,<\/span>\n<span>                  output_dim <span class=\"op\">=<\/span> <span class=\"fl\">16<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_gru<\/span><span class=\"op\">(<\/span><span class=\"fl\">8<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">layer_dense<\/span><span class=\"op\">(<\/span><span class=\"fl\">1<\/span>, activation <span class=\"op\">=<\/span> <span class=\"st\">\"sigmoid\"<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">mannequin<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">keras_model<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span>, <span class=\"va\">output<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Create a labeled dataset (which incorporates unknown tokens)<\/span><\/span>\n<span><span class=\"va\">train_dataset<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">tensor_slices_dataset<\/span><span class=\"op\">(<\/span><span class=\"fu\">checklist<\/span><span class=\"op\">(<\/span><\/span>\n<span>    <span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"st\">\"From every in keeping with his means\"<\/span>, <span class=\"st\">\"There's nothing increased than purpose.\"<\/span><span class=\"op\">)<\/span>,<\/span>\n<span>    <span class=\"fu\">c<\/span><span class=\"op\">(<\/span><span class=\"fl\">1L<\/span>, <span class=\"fl\">0L<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Preprocess the string inputs<\/span><\/span>\n<span><span class=\"va\">train_dataset<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">train_dataset<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_batch<\/span><span class=\"op\">(<\/span><span class=\"fl\">2<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">dataset_map<\/span><span class=\"op\">(<\/span><span class=\"op\">~<\/span><span class=\"fu\">checklist<\/span><span class=\"op\">(<\/span><span class=\"fu\">text_vectorizer<\/span><span class=\"op\">(<\/span><span class=\"va\">.x<\/span><span class=\"op\">)<\/span>, <span class=\"va\">.y<\/span><span class=\"op\">)<\/span>,<\/span>\n<span>              num_parallel_calls <span class=\"op\">=<\/span> <span class=\"va\">tf<\/span><span class=\"op\">$<\/span><span class=\"va\">information<\/span><span class=\"op\">$<\/span><span class=\"va\">AUTOTUNE<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Practice the mannequin<\/span><\/span>\n<span><span class=\"va\">mannequin<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">compile<\/span><span class=\"op\">(<\/span>optimizer <span class=\"op\">=<\/span> <span class=\"st\">\"adam\"<\/span>, loss <span class=\"op\">=<\/span> <span class=\"st\">\"binary_crossentropy\"<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">match<\/span><span class=\"op\">(<\/span><span class=\"va\">train_dataset<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># export inference mannequin that accepts strings as enter<\/span><\/span>\n<span><span class=\"va\">enter<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">layer_input<\/span><span class=\"op\">(<\/span>form <span class=\"op\">=<\/span> <span class=\"fl\">1<\/span>, dtype<span class=\"op\">=<\/span><span class=\"st\">\"string\"<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"va\">enter<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">text_vectorizer<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span> <span class=\"op\">%&gt;%<\/span><\/span>\n<span>  <span class=\"fu\">mannequin<\/span><span class=\"op\">(<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"va\">end_to_end_model<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">keras_model<\/span><span class=\"op\">(<\/span><span class=\"va\">enter<\/span>, <span class=\"va\">output<\/span><span class=\"op\">)<\/span><\/span>\n<span\/>\n<span><span class=\"co\"># Take a look at inference mannequin<\/span><\/span>\n<span><span class=\"va\">test_data<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">as_tensor<\/span><span class=\"op\">(<\/span><span class=\"fu\">c<\/span><span class=\"op\">(<\/span><\/span>\n<span>  <span class=\"st\">\"To every in keeping with his wants!\"<\/span>,<\/span>\n<span>  <span class=\"st\">\"Cause is, and ought solely to be the slave of the passions.\"<\/span><\/span>\n<span><span class=\"op\">)<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"va\">test_output<\/span> <span class=\"op\">&lt;-<\/span> <span class=\"fu\">end_to_end_model<\/span><span class=\"op\">(<\/span><span class=\"va\">test_data<\/span><span class=\"op\">)<\/span><\/span>\n<span><span class=\"fu\">as.array<\/span><span class=\"op\">(<\/span><span class=\"va\">test_output<\/span><span class=\"op\">)<\/span><\/span><\/code><\/pre>\n<\/div>\n<\/div>\n<h2 id=\"wrapup\">Wrapup<\/h2>\n<p>With this publish, our objective was to name consideration to <code>keras<\/code>\u2019 new pre-processing layers, and present how \u2013 and why \u2013 they&#8217;re helpful. Many extra use instances may be discovered within the vignette.<\/p>\n<p>Thanks for studying!<\/p>\n<p>Picture by Henning Borgersen on Unsplash<\/p>\n<p><!--radix_placeholder_article_footer--><\/p>\n<div class=\"article-footer\">\n<div class=\"subscribe\">\n<p>Get pleasure from this weblog? Get notified of latest posts by e mail:<\/p>\n<p>Posts additionally accessible at r-bloggers<\/p>\n<\/div>\n<\/div>\n<p><!--\/radix_placeholder_article_footer-->\n<\/div>\n<!--CusAds0-->\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>Knowledge pre-processing: What you do to the info earlier than feeding it to the mannequin.\u2014 A easy definition that, in apply, leaves open many questions. The place, precisely, ought to pre-processing cease, and the mannequin start? Are steps like normalization, or numerous numerical transforms, a part of the mannequin, or the pre-processing? What about information [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","fifu_image_alt":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-6172","post","type-post","status-publish","format-standard","has-post-thumbnail","category-world-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What they&#039;re and tips on how to use them - Profitiraj.ba<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\" \/>\n<meta property=\"og:locale\" content=\"bs_BA\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What they&#039;re and tips on how to use them - Profitiraj.ba\" \/>\n<meta property=\"og:description\" content=\"Knowledge pre-processing: What you do to the info earlier than feeding it to the mannequin.\u2014 A easy definition that, in apply, leaves open many questions. The place, precisely, ought to pre-processing cease, and the mannequin start? Are steps like normalization, or numerous numerical transforms, a part of the mannequin, or the pre-processing? What about information [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\" \/>\n<meta property=\"og:site_name\" content=\"Profitiraj.ba\" \/>\n<meta property=\"article:published_time\" content=\"2026-04-22T23:29:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\" \/>\n<meta name=\"author\" content=\"adminsata18\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"adminsata18\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minuta\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#article\",\"isPartOf\":{\"@id\":\"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/\"},\"author\":{\"name\":\"adminsata18\",\"@id\":\"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8\"},\"headline\":\"What they&#8217;re and tips on how to use them\",\"datePublished\":\"2026-04-22T23:29:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/\"},\"wordCount\":1588,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\",\"articleSection\":[\"World News\"],\"inLanguage\":\"bs-BA\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/\",\"url\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\",\"name\":\"What they're and tips on how to use them - Profitiraj.ba\",\"isPartOf\":{\"@id\":\"https:\/\/profitiraj.ba\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage\"},\"image\":{\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage\"},\"thumbnailUrl\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\",\"datePublished\":\"2026-04-22T23:29:40+00:00\",\"author\":{\"@id\":\"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8\"},\"breadcrumb\":{\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#breadcrumb\"},\"inLanguage\":\"bs-BA\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"bs-BA\",\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage\",\"url\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\",\"contentUrl\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/profitiraj.ba\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"What they&#8217;re and tips on how to use them\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/profitiraj.ba\/#website\",\"url\":\"https:\/\/profitiraj.ba\/\",\"name\":\"Profitiraj.ba\",\"description\":\"Business portal\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/profitiraj.ba\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"bs-BA\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8\",\"name\":\"adminsata18\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"bs-BA\",\"@id\":\"https:\/\/profitiraj.ba\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e4469c3417414aeb4f10bcfc9fdad7f3142b4c3297c426268cc8370c7f9726ed?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e4469c3417414aeb4f10bcfc9fdad7f3142b4c3297c426268cc8370c7f9726ed?s=96&d=mm&r=g\",\"caption\":\"adminsata18\"},\"sameAs\":[\"https:\/\/profitiraj.ba\"],\"url\":\"https:\/\/profitiraj.ba\/bs\/author\/adminsata18\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What they're and tips on how to use them - Profitiraj.ba","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:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers","og_locale":"bs_BA","og_type":"article","og_title":"What they're and tips on how to use them - Profitiraj.ba","og_description":"Knowledge pre-processing: What you do to the info earlier than feeding it to the mannequin.\u2014 A easy definition that, in apply, leaves open many questions. The place, precisely, ought to pre-processing cease, and the mannequin start? Are steps like normalization, or numerous numerical transforms, a part of the mannequin, or the pre-processing? What about information [&hellip;]","og_url":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers","og_site_name":"Profitiraj.ba","article_published_time":"2026-04-22T23:29:40+00:00","og_image":[{"url":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","type":"","width":"","height":""}],"author":"adminsata18","twitter_card":"summary_large_image","twitter_image":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","twitter_misc":{"Written by":"adminsata18","Est. reading time":"11 minuta"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#article","isPartOf":{"@id":"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/"},"author":{"name":"adminsata18","@id":"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8"},"headline":"What they&#8217;re and tips on how to use them","datePublished":"2026-04-22T23:29:40+00:00","mainEntityOfPage":{"@id":"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/"},"wordCount":1588,"commentCount":0,"image":{"@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage"},"thumbnailUrl":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","articleSection":["World News"],"inLanguage":"bs-BA","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#respond"]}]},{"@type":"WebPage","@id":"https:\/\/profitiraj.ba\/what-theyre-and-tips-on-how-to-use-them\/","url":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers","name":"What they're and tips on how to use them - Profitiraj.ba","isPartOf":{"@id":"https:\/\/profitiraj.ba\/#website"},"primaryImageOfPage":{"@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage"},"image":{"@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage"},"thumbnailUrl":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","datePublished":"2026-04-22T23:29:40+00:00","author":{"@id":"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8"},"breadcrumb":{"@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#breadcrumb"},"inLanguage":"bs-BA","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers"]}]},{"@type":"ImageObject","inLanguage":"bs-BA","@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#primaryimage","url":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg","contentUrl":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers\/images\/preview.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/blogs.rstudio.com\/tensorflow\/posts\/2021-12-09-keras-preprocessing-layers#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/profitiraj.ba\/"},{"@type":"ListItem","position":2,"name":"What they&#8217;re and tips on how to use them"}]},{"@type":"WebSite","@id":"https:\/\/profitiraj.ba\/#website","url":"https:\/\/profitiraj.ba\/","name":"Profitiraj.ba","description":"Business portal","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/profitiraj.ba\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"bs-BA"},{"@type":"Person","@id":"https:\/\/profitiraj.ba\/#\/schema\/person\/69b5bee2b7865d67d66cb799d690f0a8","name":"adminsata18","image":{"@type":"ImageObject","inLanguage":"bs-BA","@id":"https:\/\/profitiraj.ba\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e4469c3417414aeb4f10bcfc9fdad7f3142b4c3297c426268cc8370c7f9726ed?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e4469c3417414aeb4f10bcfc9fdad7f3142b4c3297c426268cc8370c7f9726ed?s=96&d=mm&r=g","caption":"adminsata18"},"sameAs":["https:\/\/profitiraj.ba"],"url":"https:\/\/profitiraj.ba\/bs\/author\/adminsata18\/"}]}},"_links":{"self":[{"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/posts\/6172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/comments?post=6172"}],"version-history":[{"count":1,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/posts\/6172\/revisions"}],"predecessor-version":[{"id":6173,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/posts\/6172\/revisions\/6173"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/media\/6174"}],"wp:attachment":[{"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/media?parent=6172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/categories?post=6172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/profitiraj.ba\/bs\/wp-json\/wp\/v2\/tags?post=6172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}