{"id":9432,"date":"2024-03-12T07:44:42","date_gmt":"2024-03-12T15:44:42","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=9432"},"modified":"2025-04-24T17:02:58","modified_gmt":"2025-04-24T17:02:58","slug":"transfer-learning-with-comet","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet\/","title":{"rendered":"Navigating Transfer Learning with Comet"},"content":{"rendered":"\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96\" alt=\"\" width=\"700\" height=\"875\"><\/figure><div class=\"mh mi ee mj bg mk\" tabindex=\"0\" role=\"button\">\n<h2 class=\"ly lz ma\"><picture><\/picture><\/h2>\n<\/div><figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Photo by <a class=\"af mr\" href=\"https:\/\/unsplash.com\/@danielkorpai?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Daniel Korpai<\/a> on <a class=\"af mr\" href=\"https:\/\/unsplash.com\/?utm_source=medium&amp;utm_medium=referral\" target=\"_blank\" rel=\"noopener ugc nofollow\">Unsplash<\/a><\/figcaption><\/figure>\n<p id=\"6580\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Transfer learning involves using a pre-trained model to solve a deep-learning problem. If your problem is not necessarily unique, it is better to create a model that has already been trained on a given task.<\/p>\n<p id=\"6ad6\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Comet extensively integrates with multiple libraries, including the most common ones for deep learning, such as TensorFlow, Keras, and Pytorch.<\/p>\n<p id=\"3cee\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">These integrations are well-supported and allow extensive types of workflows, including those that require transfer learning. This article will dive deep into how you can make great observations and visualizations with Comet. I will also indicate how easy it is to integrate Comet with previous projects, as it takes a few lines of code here and there to get things running.<\/p>\n<p id=\"2043\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Now, for this task, you will need a few things:<\/p>\n<ol class=\"\">\n<li id=\"b627\" class=\"ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn no np nq bj\" data-selectable-paragraph=\"\">A Comet account. Sign up <a class=\"af mr\" href=\"\/signup\" target=\"_blank\" rel=\"noopener ugc nofollow\">here<\/a>.<\/li>\n<li id=\"a8e6\" class=\"ms mt fr mu b gp nr mw mx gs ns mz na nb nt nd ne nf nu nh ni nj nv nl nm nn no np nq bj\" data-selectable-paragraph=\"\">A Python 3.9+ install.<\/li>\n<li id=\"2f18\" class=\"ms mt fr mu b gp nr mw mx gs ns mz na nb nt nd ne nf nu nh ni nj nv nl nm nn no np nq bj\" data-selectable-paragraph=\"\">The following libraries: Comet, ScikitLearn, Pandas, and Keras.<\/li>\n<li id=\"b2a2\" class=\"ms mt fr mu b gp nr mw mx gs ns mz na nb nt nd ne nf nu nh ni nj nv nl nm nn no np nq bj\" data-selectable-paragraph=\"\">A fierce learning spirit.<\/li>\n<\/ol>\n<p id=\"2b77\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Let&#8217;s dive into the tiny project now.<\/p>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<h2 id=\"993a\" class=\"oe of fr be og oh oi oj ok ol om on oo nb op oq or nf os ot ou nj ov ow ox oy bj\" data-selectable-paragraph=\"\">Project Overview<\/h2>\n<p id=\"87cf\" class=\"pw-post-body-paragraph ms mt fr mu b gp oz mw mx gs pa mz na nb pb nd ne nf pc nh ni nj pd nl nm nn fk bj\" data-selectable-paragraph=\"\">In our tiny project, I will use one of my favorite datasets. The beauty of this dataset is that it has just the right amount of difficulty to ensure that you learn numerous concepts in a deep learning problem. We are going to be using data from Kaggle&#8217;s famous <a class=\"af mr\" href=\"https:\/\/www.kaggle.com\/competitions\/dogs-vs-cats-redux-kernels-edition\/data\" target=\"_blank\" rel=\"noopener ugc nofollow\">Cats-and-Dogs<\/a> problem.<\/p>\n<p id=\"d1f3\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">The objective here is not to gain perfection or even high accuracy, as this is purely a learning exercise; hence, there are a few tradeoffs that I will highlight here.<\/p>\n<p id=\"b27a\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">We are going to build a simple, bare-bones model and train it only on a very small sample of the data we downloaded. The data will only be trained for a few epochs. From this, we can ascertain that there will be poor accuracy. It could be better with proper interventions, though.<\/p>\n<p id=\"763f\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Since that is established, let&#8217;s code.<\/p>\n<h2 id=\"ce07\" class=\"pe of fr be og pf pg gr ok ph pi gu oo pj pk pl pm pn po pp pq pr ps pt pu pv bj\">Dataset Preparation<\/h2>\n<p id=\"5638\" class=\"pw-post-body-paragraph ms mt fr mu b gp oz mw mx gs pa mz na nb pb nd ne nf pc nh ni nj pd nl nm nn fk bj\" data-selectable-paragraph=\"\">We first store the information in the dataset in a Pandas DataFrame. The DataFrame will contain two columns: one for the file names and the other for each image&#8217;s class.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"d765\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n<span class=\"hljs-keyword\">import<\/span> os\n\ntrain_dir = <span class=\"hljs-string\">r\".\/src\/train_data\"<\/span>\n\n<span class=\"hljs-comment\">#path to training data<\/span>\nfilenames = os.listdir(train_dir)\n\n<span class=\"hljs-comment\">#separating cats from dogs<\/span>\ncategories = []\n<span class=\"hljs-keyword\">for<\/span> f_name <span class=\"hljs-keyword\">in<\/span> filenames:\n    category = f_name.split(<span class=\"hljs-string\">'.'<\/span>)[<span class=\"hljs-number\">0<\/span>]\n    <span class=\"hljs-keyword\">if<\/span> category == <span class=\"hljs-string\">'cat'<\/span>:\n        categories.append(<span class=\"hljs-number\">0<\/span>)\n    <span class=\"hljs-keyword\">else<\/span>:\n        categories.append(<span class=\"hljs-number\">1<\/span>)\n\ndf = pd.DataFrame({\n        <span class=\"hljs-string\">'filename'<\/span>: filenames,\n        <span class=\"hljs-string\">'category'<\/span>: categories,\n})\n\n<span class=\"hljs-comment\">#replacing booleans with names<\/span>\ndf[<span class=\"hljs-string\">\"category\"<\/span>] = df[<span class=\"hljs-string\">\"category\"<\/span>].replace({<span class=\"hljs-number\">0<\/span>:<span class=\"hljs-string\">'cat'<\/span>, <span class=\"hljs-number\">1<\/span>:<span class=\"hljs-string\">'dog'<\/span>})\n\n<span class=\"hljs-comment\">#storing info in csv files<\/span>\ndf.to_csv(<span class=\"hljs-string\">\"new_training_info.csv\"<\/span>, index=<span class=\"hljs-literal\">False<\/span>)<\/span><\/pre>\n<p id=\"a88f\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">After doing this, the table will look as follows:<\/p>\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:480\/1*XjPPuE7F2hFJA6OO4jpuEw.png\" alt=\"\" width=\"480\" height=\"270\"><\/figure><div class=\"ly lz qf\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:960\/format:webp\/1*XjPPuE7F2hFJA6OO4jpuEw.png 960w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 480px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*XjPPuE7F2hFJA6OO4jpuEw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*XjPPuE7F2hFJA6OO4jpuEw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*XjPPuE7F2hFJA6OO4jpuEw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*XjPPuE7F2hFJA6OO4jpuEw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*XjPPuE7F2hFJA6OO4jpuEw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*XjPPuE7F2hFJA6OO4jpuEw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:960\/1*XjPPuE7F2hFJA6OO4jpuEw.png 960w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 480px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Screenshot by author<\/figcaption>\n<\/figure>\n<h2 id=\"30e5\" class=\"pe of fr be og pf pg gr ok ph pi gu oo pj pk pl pm pn po pp pq pr ps pt pu pv bj\">Parameter Definition<\/h2>\n<p id=\"e511\" class=\"pw-post-body-paragraph ms mt fr mu b gp oz mw mx gs pa mz na nb pb nd ne nf pc nh ni nj pd nl nm nn fk bj\" data-selectable-paragraph=\"\">We need to define a few parameters. One set will go into the model, while the other will be fed into the DataLoaders.<\/p>\n<p id=\"7f2c\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">The parameters belonging to the model will be logged into Comet, allowing the training process to be monitored and properly visualized.<\/p>\n<p id=\"fa06\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Our parameters will appear as below:<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"012c\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\">img_height = <span class=\"hljs-number\">224<\/span>\nimg_width = <span class=\"hljs-number\">224<\/span>\nimg_channels = <span class=\"hljs-number\">3<\/span>\nimg_size = (img_height, img_width)\ntrain_dir = <span class=\"hljs-string\">r\".\/src\/train_data\"<\/span>\nbatch_size = <span class=\"hljs-number\">32<\/span><\/span><\/pre>\n<p id=\"54b8\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">The image fed into the model we will use will be 224 x 224 x 3 pixels, so all the images must be transformed into these sizes. The model will take batches of 32 images for training from the &#8220;train_data&#8221; directory.<\/p>\n<h2 id=\"aa3f\" class=\"pe of fr be og pf pg gr ok ph pi gu oo pj pk pl pm pn po pp pq pr ps pt pu pv bj\">Initializing Comet and Data Generators<\/h2>\n<p id=\"8886\" class=\"pw-post-body-paragraph ms mt fr mu b gp oz mw mx gs pa mz na nb pb nd ne nf pc nh ni nj pd nl nm nn fk bj\" data-selectable-paragraph=\"\">Import the Comet library and initialize it by giving the project a name. This project will appear on your Comet home page. Most importantly, you will be requested to add an API key, which you can easily find on your account&#8217;s &#8220;Settings&#8221; page.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"5d18\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-keyword\">import<\/span> comet_ml\n\ncomet_ml.login(project_name=<span class=\"hljs-string\">\"transfer_learning_training\"<\/span>)<\/span><\/pre>\n<p id=\"a2e8\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">After pasting your API key, you will get the image below.<\/p>\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<div class=\"mh mi ee mj bg mk\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:578\/1*OtJLL0LeQ9IpOAMiVOuYNw.png\" alt=\"\" width=\"578\" height=\"180\"><\/figure><div class=\"ly lz qg\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1156\/format:webp\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 1156w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 578px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1156\/1*OtJLL0LeQ9IpOAMiVOuYNw.png 1156w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 578px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Screenshot by author<\/figcaption>\n<\/figure>\n<p id=\"adad\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">The next step is to allow Comet to monitor our parameters. These parameters will be logged.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"3a47\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-keyword\">from<\/span> comet_ml <span class=\"hljs-keyword\">import<\/span> Experiment\n\n<span class=\"hljs-comment\">#initializing comet experiment<\/span>\nexperiment = Experiment()\n\nparameters = {\n    <span class=\"hljs-string\">\"batch_size\"<\/span>:batch_size,\n    <span class=\"hljs-string\">\"epochs\"<\/span>: <span class=\"hljs-number\">5<\/span>,\n    <span class=\"hljs-string\">\"optimizer\"<\/span>: <span class=\"hljs-string\">\"adam\"<\/span>,\n    <span class=\"hljs-string\">\"loss\"<\/span>: <span class=\"hljs-string\">\"binary_crossentropy\"<\/span>,\n}\n<span class=\"hljs-comment\">#Logging Parameters<\/span>\nexperiment.log_parameters(parameters)<\/span><\/pre>\n<p id=\"3632\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">We can now create data generators for our training and validation data fed into the models. Here, we will perform the necessary transformations on the images.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"65b9\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-keyword\">from<\/span> sklearn.model_selection <span class=\"hljs-keyword\">import<\/span> train_test_split\n<span class=\"hljs-keyword\">from<\/span> keras.preprocessing.image <span class=\"hljs-keyword\">import<\/span> ImageDataGenerator\n\n\n<span class=\"hljs-comment\">#Importing dataframe<\/span>\ndf = pd.read_csv(<span class=\"hljs-string\">\"new_training_info.csv\"<\/span>)\n\n<span class=\"hljs-comment\">#performing training and validation splits<\/span>\ntrain_df, validation_df = train_test_split(df,test_size=<span class=\"hljs-number\">0.2<\/span>, random_state=<span class=\"hljs-number\">42<\/span>)\n\n<span class=\"hljs-comment\">#preparing data generators<\/span>\ntrain_datagen = ImageDataGenerator(rotation_range=<span class=\"hljs-number\">15<\/span>,\n                                   rescale=<span class=\"hljs-number\">1.<\/span>\/<span class=\"hljs-number\">255<\/span>,\n                                   shear_range=<span class=\"hljs-number\">0.1<\/span>,\n                                   zoom_range=<span class=\"hljs-number\">0.2<\/span>,\n                                   horizontal_flip=<span class=\"hljs-literal\">True<\/span>,\n                                   width_shift_range=<span class=\"hljs-number\">0.1<\/span>,\n                                   height_shift_range=<span class=\"hljs-number\">0.1<\/span>)\n\n\ntrain_gen = train_datagen.flow_from_dataframe(train_df,\n                                              train_dir, x_col=<span class=\"hljs-string\">'filename'<\/span>, y_col=<span class=\"hljs-string\">'category'<\/span>,\n                                              target_size=img_size,\n                                              class_mode=<span class=\"hljs-string\">'binary'<\/span>,\n                                              batch_size=batch_size)\n\nvalidation_datagen = ImageDataGenerator(rescale=<span class=\"hljs-number\">1.<\/span>\/<span class=\"hljs-number\">255<\/span>)\n\n\nvalidation_gen = validation_datagen.flow_from_dataframe(train_df,\n                                              train_dir, x_col=<span class=\"hljs-string\">'filename'<\/span>, y_col=<span class=\"hljs-string\">'category'<\/span>,\n                                              target_size=img_size,\n                                              class_mode=<span class=\"hljs-string\">'binary'<\/span>,\n                                              batch_size=batch_size)<\/span><\/pre>\n<p id=\"206f\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Now that that part is complete, we can use transfer learning using a pre-trained model.<\/p>\n<h2 id=\"63f3\" class=\"pe of fr be og pf pg gr ok ph pi gu oo pj pk pl pm pn po pp pq pr ps pt pu pv bj\">Transfer Learning<\/h2>\n<p id=\"5bfa\" class=\"pw-post-body-paragraph ms mt fr mu b gp oz mw mx gs pa mz na nb pb nd ne nf pc nh ni nj pd nl nm nn fk bj\" data-selectable-paragraph=\"\">We are going to use a ResNet50 as the base model, and we will add a few layers on top of it.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"115b\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-comment\">#model creation and training<\/span>\n<span class=\"hljs-keyword\">from<\/span> keras.applications.resnet <span class=\"hljs-keyword\">import<\/span> ResNet50\n<span class=\"hljs-keyword\">from<\/span> keras.layers <span class=\"hljs-keyword\">import<\/span> Dense, Flatten\n<span class=\"hljs-keyword\">from<\/span> keras.models <span class=\"hljs-keyword\">import<\/span> Sequential\n<span class=\"hljs-keyword\">from<\/span> keras.callbacks <span class=\"hljs-keyword\">import<\/span> EarlyStopping\n\n<span class=\"hljs-comment\">#initialize sequential model<\/span>\nmodel = Sequential()\n\n<span class=\"hljs-comment\">#base model<\/span>\nbase = ResNet50(weights= <span class=\"hljs-string\">'imagenet'<\/span>,\n                 include_top=<span class=\"hljs-literal\">False<\/span>,\n                 input_shape=(img_height, img_width, img_channels),\n                 classes=<span class=\"hljs-number\">2<\/span>\n                 )\n\n<span class=\"hljs-keyword\">for<\/span> layer <span class=\"hljs-keyword\">in<\/span> base.layers:\n    layer.trainable = <span class=\"hljs-literal\">False<\/span>\n\n<span class=\"hljs-comment\">#Adding layers to the model<\/span>\nmodel.add(base)\nmodel.add(Flatten())\nmodel.add(Dense(<span class=\"hljs-number\">512<\/span>, activation=<span class=\"hljs-string\">'relu'<\/span>))\nmodel.add(Dense(<span class=\"hljs-number\">1<\/span>, activation=<span class=\"hljs-string\">'sigmoid'<\/span>))\n\n<span class=\"hljs-comment\">#EarlyStopping callback<\/span>\ncallback = EarlyStopping(monitor=<span class=\"hljs-string\">'loss'<\/span>,\n                         patience=<span class=\"hljs-number\">0<\/span>)<\/span><\/pre>\n<p id=\"abf8\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Above, we define our ResNet50 model and highlight the number of classes we train (only 2). We also specify the shape of the image that we want.<\/p>\n<p id=\"849c\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">We will now compile the model and train it. Training will be recorded as a live event on your &#8220;Project page&#8221; in Comet. It will be indicated as complete once we run the &#8220;experiment.end()&#8221; function provided by Comet.<\/p>\n<p id=\"43be\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Let&#8217;s first see the structure of our model:<\/p>\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:598\/1*zZ1hL9VUozlFh4_TXk4KiA.png\" alt=\"\" width=\"598\" height=\"391\"><\/figure><div class=\"ly lz qh\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1196\/format:webp\/1*zZ1hL9VUozlFh4_TXk4KiA.png 1196w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 598px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*zZ1hL9VUozlFh4_TXk4KiA.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*zZ1hL9VUozlFh4_TXk4KiA.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*zZ1hL9VUozlFh4_TXk4KiA.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*zZ1hL9VUozlFh4_TXk4KiA.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*zZ1hL9VUozlFh4_TXk4KiA.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*zZ1hL9VUozlFh4_TXk4KiA.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1196\/1*zZ1hL9VUozlFh4_TXk4KiA.png 1196w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 598px\" data-testid=\"og\"><\/picture><\/div>\n<figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Screenshot by author<\/figcaption>\n<\/figure>\n<p id=\"42b2\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">The model can then be compiled using the parameters we initially logged to Comet.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"4dcd\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\">model.<span class=\"hljs-built_in\">compile<\/span>(loss=parameters[<span class=\"hljs-string\">\"loss\"<\/span>],\n              optimizer=parameters[<span class=\"hljs-string\">\"optimizer\"<\/span>],\n              metrics=[<span class=\"hljs-string\">\"accuracy\"<\/span>])<\/span><\/pre>\n<p id=\"cd83\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">We will do the same when training the model.<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"ab4e\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\"><span class=\"hljs-comment\">#removing validation_steps and steps_per_epoch<\/span>\nmodel.fit_generator(train_gen,\n                    validation_data = validation_gen,\n                    epochs=parameters[<span class=\"hljs-string\">\"epochs\"<\/span>],\n                    callbacks=[callback])<\/span><\/pre>\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<div class=\"mh mi ee mj bg mk\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*MYTYVXI4R6lsDxzsDlMYqQ.png\" alt=\"\" width=\"700\" height=\"94\"><\/figure><div class=\"ly lz qi\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*MYTYVXI4R6lsDxzsDlMYqQ.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Screenshot by author<\/figcaption>\n<\/figure>\n<p id=\"8028\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Training occurs for five epochs, and now we can open our Comet &#8220;Project&#8221; page and check whether all the information we want has been logged and visualized.<\/p>\n<figure class=\"mb mc md me mf mg ly lz paragraph-image\">\n<div class=\"mh mi ee mj bg mk\" tabindex=\"0\" role=\"button\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"bg lf ml c\" role=\"presentation\" src=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/1*M3Zvlqpfkh4v95YmZk49JQ.png\" alt=\"\" width=\"700\" height=\"296\"><\/figure><div class=\"ly lz qj\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*M3Zvlqpfkh4v95YmZk49JQ.png 1400w\" type=\"image\/webp\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*M3Zvlqpfkh4v95YmZk49JQ.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*M3Zvlqpfkh4v95YmZk49JQ.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*M3Zvlqpfkh4v95YmZk49JQ.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*M3Zvlqpfkh4v95YmZk49JQ.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*M3Zvlqpfkh4v95YmZk49JQ.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*M3Zvlqpfkh4v95YmZk49JQ.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*M3Zvlqpfkh4v95YmZk49JQ.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" data-testid=\"og\"><\/picture><\/div>\n<\/div>\n<figcaption class=\"mm mn mo ly lz mp mq be b bf z dw\" data-selectable-paragraph=\"\">Screenshot by author<\/figcaption>\n<\/figure>\n<p id=\"405f\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">We can see that our visualizations have been made. The loss and accuracy charts for the training and validation sets are available.<\/p>\n<p id=\"f8d6\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">To end the run, one should add the line below:<\/p>\n<pre class=\"mb mc md me mf pw px py bo pz ba bj\"><span id=\"c1ef\" class=\"qa of fr px b bf qb qc l qd qe\" data-selectable-paragraph=\"\">experiment.end()<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"ab ca nw nx ny nz\" role=\"separator\"><span style=\"font-family: var(--wpex-body-font-family, var(--wpex-font-sans)); font-size: var(--wpex-body-font-size, 13px);\">As shown above, Comet successfully logged the transfer learning run. However, it was fairly inaccurate, as I did not use various techniques to improve model performance. Some of the techniques that could be used to do this include data augmentation and resampling to give but a few examples.<\/span><\/div>\n\n\n\n<div class=\"fk fl fm fn fo\">\n<div class=\"ab ca\">\n<div class=\"ch bg ew ex ey ez\">\n<p id=\"e98a\" class=\"pw-post-body-paragraph ms mt fr mu b gp mv mw mx gs my mz na nb nc nd ne nf ng nh ni nj nk nl nm nn fk bj\" data-selectable-paragraph=\"\">Till we meet again!!<\/p>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Photo by Daniel Korpai on Unsplash Transfer learning involves using a pre-trained model to solve a deep-learning problem. If your problem is not necessarily unique, it is better to create a model that has already been trained on a given task. Comet extensively integrates with multiple libraries, including the most common ones for deep learning, [&hellip;]<\/p>\n","protected":false},"author":79,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[6,9,7],"tags":[],"coauthors":[176],"class_list":["post-9432","post","type-post","status-publish","format-standard","hentry","category-machine-learning","category-product","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Navigating Transfer Learning with Comet<\/title>\n<meta name=\"description\" content=\"Learn how you can make great observations and visualizations with Comet, using transfer learning and ScikitLearn, Pandas, and Keras.\" \/>\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.comet.com\/site\/blog\/transfer-learning-with-comet\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Navigating Transfer Learning with Comet\" \/>\n<meta property=\"og:description\" content=\"Learn how you can make great observations and visualizations with Comet, using transfer learning and ScikitLearn, Pandas, and Keras.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-12T15:44:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:02:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96\" \/>\n<meta name=\"author\" content=\"Mwanikii Njagi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mwanikii Njagi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Navigating Transfer Learning with Comet","description":"Learn how you can make great observations and visualizations with Comet, using transfer learning and ScikitLearn, Pandas, and Keras.","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.comet.com\/site\/blog\/transfer-learning-with-comet","og_locale":"en_US","og_type":"article","og_title":"Navigating Transfer Learning with Comet","og_description":"Learn how you can make great observations and visualizations with Comet, using transfer learning and ScikitLearn, Pandas, and Keras.","og_url":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2024-03-12T15:44:42+00:00","article_modified_time":"2025-04-24T17:02:58+00:00","og_image":[{"url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96","type":"","width":"","height":""}],"author":"Mwanikii Njagi","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Mwanikii Njagi","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet\/"},"author":{"name":"Mwanikii Njagi","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/c7043b3e6b992af7b3220aa1f27d2162"},"headline":"Navigating Transfer Learning with Comet","datePublished":"2024-03-12T15:44:42+00:00","dateModified":"2025-04-24T17:02:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet\/"},"wordCount":805,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96","articleSection":["Machine Learning","Product","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet\/","url":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet","name":"Navigating Transfer Learning with Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#primaryimage"},"thumbnailUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96","datePublished":"2024-03-12T15:44:42+00:00","dateModified":"2025-04-24T17:02:58+00:00","description":"Learn how you can make great observations and visualizations with Comet, using transfer learning and ScikitLearn, Pandas, and Keras.","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#primaryimage","url":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96","contentUrl":"https:\/\/miro.medium.com\/v2\/resize:fit:700\/0*3SgLgEnaaG9dFM96"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/transfer-learning-with-comet#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Navigating Transfer Learning with Comet"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/c7043b3e6b992af7b3220aa1f27d2162","name":"Mwanikii Njagi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/1a3c516cf04aca9418dfb2213081f4df","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/cropped-1_2jy9gyk0G_yaniWm8gJFVA-1-96x96.webp","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2023\/08\/cropped-1_2jy9gyk0G_yaniWm8gJFVA-1-96x96.webp","caption":"Mwanikii Njagi"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/freddynjagigmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/79"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=9432"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9432\/revisions"}],"predecessor-version":[{"id":15374,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9432\/revisions\/15374"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=9432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=9432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=9432"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=9432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}