{"id":79948,"date":"2020-09-29T09:00:23","date_gmt":"2020-09-29T03:30:23","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=79948"},"modified":"2020-09-29T09:00:23","modified_gmt":"2020-09-29T03:30:23","slug":"modules-of-keras","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/","title":{"rendered":"Modules of Keras"},"content":{"rendered":"<p>Keras is an emerging trend in the field of Deep Learning. It is a high-level neural network API that runs on the top of TensorFlow and Theano. It does not handle low-level computations.<\/p>\n<p>Keras uses its backend engines to perform the selective tasks that Keras is not capable of. It focuses on fast experimentations. Its main ideology is the Model. Keras is the best library available for Deep Learning. It is simple and readable.<\/p>\n<p>It is a user-friendly Keras library. Let us learn about Modules of Keras.<\/p>\n<h3>Modules of Keras<\/h3>\n<p>Keras Module consists of pre-defined classes, functions, operations, and variables that are useful for Deep Learning. These Keras modules help users to complete their tasks easily. It saves their computing time.<\/p>\n<p>It gives user\u2019s the opportunity to use predefined functions and classes to simplify their work.<\/p>\n<p>There are various Keras Modules available:<\/p>\n<h4>1. Keras Activators Module<\/h4>\n<p>These modules contain built-in activation functions. It offers you a list of activation functions.<\/p>\n<h4>2. Keras Constraints Module<\/h4>\n<p>It gives you a list of constraint functions. These functions impose constraints on the weight values.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras.constraints import max_norm\nmodel.add(Dense(64, kernel_constraint=max_norm(2.)))\n<\/pre>\n<h4>3. Keras Callbacks Module<\/h4>\n<p>It contains a list of callback functions. You can call these functions while training the model. You can either use these functions to get the intermediate data or to stop the training of the model.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">keras.callbacks.callbacks.Callback()\n<\/pre>\n<h4>4. Keras Backend Module<\/h4>\n<p>It enables you to use the functions of the backend libraries like TensorFlow and Theano. It is useful for Keras backend operations. To use Keras backend Module, prefer the code below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras import backend as k\n<\/pre>\n<p>Some of the backend modules are:<\/p>\n<ul>\n<li><strong>to_dense():<\/strong> It is used to converts sparse into dense.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">b = k.to_dense(a) \nprint(b) Tensor(\"SparseToDense:0\", shape = (2, 2), dtype = float32) \nprint(k.is_sparse(b)) False\n<\/pre>\n<ul>\n<li><strong>variable():<\/strong> It is used to initializes a variable.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">data = k.variable([[10,20,30,40],[50,60,70,80]])<\/pre>\n<ul>\n<li><strong>batch_dot()<\/strong><\/li>\n<li><strong>reset_uids()<\/strong><\/li>\n<li><strong>random_unifrom_variable()<\/strong><\/li>\n<li><strong>dot(): It is used to multiply two tensors.<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">a = k.placeholder(shape = (4,2)) \nb = k.placeholder(shape = (2,3)) \nc = k.dot(a,b) \nc \n&lt;tf.Tensor 'MatMul_3:0' shape = (4, 3) dtype = float32&gt; \n<\/pre>\n<ul>\n<li><strong>ones():<\/strong> It is used to initialize all as one value.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">res = k.ones(shape = (2,2))<\/pre>\n<ul>\n<li><strong>placeholder():<\/strong> It is useful for instantiates a placeholder tensor.<\/li>\n<\/ul>\n<h4>5. Keras Optimizers Module<\/h4>\n<p>It gives you a list of optimizers\u2019 functions. It contains built-in optimizer classes.<\/p>\n<h4>6. Keras Utils Module<\/h4>\n<p>It is very useful in Deep Learning. It provides you with a list of utility functions and built-in utility classes. Some of the methods that the utils module provide are:<\/p>\n<ul>\n<li><strong>to_categorical()<\/strong><\/li>\n<li><strong>plot_model():<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras.utils import plot_model \nplot_model(model,to_file = 'image.png')\n<\/pre>\n<ul>\n<li><strong>HDF5Matrix():<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras.utils import HDF5Matrix data = HDF5Matrix('data.hdf5', 'data')\n<\/pre>\n<ul>\n<li><strong>print_summary():<\/strong><\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">From keras.utils import print_summary print_summary(model)\n<\/pre>\n<h4>7. Keras Initializers Module<\/h4>\n<p>It is Keras initializer serialization or deserialization. It contains a list of initializer functions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">keras.initializers.Initializer()\n<\/pre>\n<h4>8. Keras Losses Module<\/h4>\n<p>It enables you to use built-in losses functions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras import losses\nmodel.compile(loss=losses.mean_squared_error, optimizer='sgd')\n<\/pre>\n<h4>9. Keras Regularizers Module<\/h4>\n<p>It has a list of regularizer functions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from keras import regularizers\n<\/pre>\n<h4>10. Keras Models Module<\/h4>\n<p>It contains model-related API entries. It has a clone code for model-cloning.<\/p>\n<h4>11. Keras Metrics Module<\/h4>\n<p>It provides you a list of built-in metrics functions. It enables you to use them while dealing with metrics.<\/p>\n<h4>12. Keras Text processing Module<\/h4>\n<p>It provides you functions. These functions enable you to convert text to a NumPy array. It is suitable for Machine Learning.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">keras.preprocessing.text.Tokenizer()<\/pre>\n<h4>13. Keras Pre-processing Module<\/h4>\n<p>This module provides you with Keras data pre-processing utlis.<\/p>\n<h4>14. Keras Layer Module<\/h4>\n<p>It contains a list of Keras Layers API.<\/p>\n<h4>15. Keras Image-processing Module<\/h4>\n<p>It is a useful module for Machine Learning. It can be helpful in the Data Preparation Phase of ML. it contains functions that allow you to convert the image into a NumPy array.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">keras.preprocessing.image.ImageDataGenerator()v<\/pre>\n<h3>Conclusion<\/h3>\n<p>Keras is a very powerful and famous Python library. It is useful while dealing with Deep Learning. It is not capable to perform low-level computations. Hence, it uses backend engines like TensorFlow, Microsoft CNTK, and Theano.<\/p>\n<p>Keras runs on the top of these backend engines. Keras focuses on fast implementations by providing you Keras Modules. These modules are a set of pre-defined functions and operations.<\/p>\n<p>These modules reduce complexity while working with Deep Learning. These are user-friendly modules. It allows users to implement modules in a simple way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Keras is an emerging trend in the field of Deep Learning. It is a high-level neural network API that runs on the top of TensorFlow and Theano. It does not handle low-level computations. Keras&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":79988,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3263],"tags":[3283,3284],"class_list":["post-79948","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-keras-tutorials","tag-keras-modules","tag-modules-of-keras"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Modules of Keras - TechVidvan<\/title>\n<meta name=\"description\" content=\"Modules of Keras are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Modules of Keras - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Modules of Keras are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-29T03:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Modules of Keras - TechVidvan","description":"Modules of Keras are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning.","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:\/\/techvidvan.com\/tutorials\/modules-of-keras\/","og_locale":"en_US","og_type":"article","og_title":"Modules of Keras - TechVidvan","og_description":"Modules of Keras are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning.","og_url":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-09-29T03:30:23+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Modules of Keras","datePublished":"2020-09-29T03:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/"},"wordCount":617,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg","keywords":["keras modules","Modules of Keras"],"articleSection":["Keras Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/","url":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/","name":"Modules of Keras - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg","datePublished":"2020-09-29T03:30:23+00:00","description":"Modules of Keras are a set of pre-defined functions and operations. These modules reduce complexity while working with Deep Learning.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/Modules-of-Keras-for-TV.jpg","width":802,"height":420,"caption":"Modules of Keras"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/modules-of-keras\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Modules of Keras"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/79948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=79948"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/79948\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/79988"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=79948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=79948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=79948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}