{
  "id": 165217,
  "title": "EfficientNet usage in R",
  "url": "/competitions/siim-isic-melanoma-classification/discussion/165217",
  "author_name": "KCKamojjala",
  "post_date": "2020-07-08T20:57:31.370000",
  "votes": 1,
  "comment_count": 25,
  "views": 0,
  "content": "<p>Hello Everyone,</p>\n\n<p>I have just started to dive into deep learning using R. For this competition, I have seen a lot of notebooks using efficientnet models in their implementations. I have been working with other pre-trained networks but not to good success and at the same time,  I am not able to load efficientnet in my R code.</p>\n\n<p>Currently, I am using Keras 2.2.5 and tensorflow 2.2.0 version. I googled for efficientnet examples in R as well but could not find any. I understand that most of the users here are python experts but could someone please let me know if I can load efficientnet models at all in R ?</p>\n\n<p>So far, I have installed the efficientnet 1.1.0 python package using pip but I am not able to import it into RStudio. When I try to install the same package via RStudio, it says \"package ‘efficientnet’ is not available (for R version 3.6.2)\"</p>\n\n<p>Any help is appreciated.</p>\n\n<p>Thanks\nKC</p>",
  "messages": [
    {
      "id": 1008806,
      "postDate": "2020-09-13T12:07:33.940Z",
      "content": "<p>(shameless autopromition) It is a bit old, but here an efficientnet working on kaggle ;p <a href=\"https://www.kaggle.com/cdk292/efficientnet0-with-r\" target=\"_blank\">https://www.kaggle.com/cdk292/efficientnet0-with-r</a> </p>",
      "rawMarkdown": "(shameless autopromition) It is a bit old, but here an efficientnet working on kaggle ;p https://www.kaggle.com/cdk292/efficientnet0-with-r ",
      "votes": 1
    },
    {
      "id": 922332,
      "postDate": "2020-07-10T03:10:50.683Z",
      "content": "<p>I would try this</p>\n\n<p>library(reticulate)\npy_run_string(\"import efficientnet.keras as efn\")</p>\n\n<p>py_run_string(\"base_model = efn.EfficientNetB4(input_shape=(dim, dim, 3), weights=\\\"imagenet\\\", include_top=False, pooling=\\\"avg\\\"\")</p>\n\n<p>base_model=py$base_model</p>\n\n<p>and add layers to base_model</p>",
      "rawMarkdown": "I would try this\n\nlibrary(reticulate)\npy\\_run\\_string(\"import efficientnet.keras as efn\")\n\npy\\_run\\_string(\"base\\_model = efn.EfficientNetB4(input\\_shape=(dim, dim, 3), weights=\\\"imagenet\\\", include\\_top=False, pooling=\\\"avg\\\"\")\n\nbase\\_model=py$base_model\n\nand add layers to base\\_model",
      "votes": 2,
      "replies": [
        {
          "id": 922352,
          "postDate": "2020-07-10T03:38:21.610Z",
          "content": "<p>Thanks a lot <a href=\"/kittlein\">@kittlein</a> . I will let you know how it goes !</p>",
          "rawMarkdown": "Thanks a lot @kittlein . I will let you know how it goes !",
          "votes": 1
        },
        {
          "id": 926804,
          "postDate": "2020-07-13T02:35:30.397Z",
          "rawMarkdown": "",
          "isDeleted": true
        },
        {
          "id": 926805,
          "postDate": "2020-07-13T02:42:17.287Z",
          "content": "<p><a href=\"/kittlein\">@kittlein</a> <a href=\"/cdk292\">@cdk292</a> Hi Marcelo, I was able to import EfficientNet in R using your code (thats an improvement for me 😊 ). However, when I tried to add layers to it, it started to throw me errors ( Error:TypeError: The added layer must be an instance of class Layer. Found:  )</p>\n\n<p>I will try to get that fixed and I was using the exact same syntax as for other pre-trained nets. A sample is shown below</p>\n\n<hr>\n\n<p>library(reticulate)\npy_run_string(\"import efficientnet.keras as efn\")\npy_run_string(\"base_model = efn.EfficientNetB4(input_shape=(224, 224, 3), weights=\\\"imagenet\\\", include_top=False, pooling=\\\"avg\\\")\")\nconv_base &lt;- py$base_model</p>\n\n<p>model&lt;- keras_model_sequential() %&gt;%\n  conv_base %&gt;% \n  layer_flatten() %&gt;%\n  layer_dense(units = 1, activation = \"sigmoid\")</p>\n\n<hr>",
          "rawMarkdown": "@kittlein @cdk292 Hi Marcelo, I was able to import EfficientNet in R using your code (thats an improvement for me 😊 ). However, when I tried to add layers to it, it started to throw me errors ( Error:TypeError: The added layer must be an instance of class Layer. Found: ",
          "votes": 1
        },
        {
          "id": 930150,
          "postDate": "2020-07-15T08:25:44.907Z",
          "content": "<p><a href=\"/kckamojjala\">@kckamojjala</a> also I think the following could work : </p>\n\n<p><code>\n`tf&amp;lt;-import(\"tensorflow\")\ntf$keras$applications$`\n</code></p>\n\n<p>or</p>\n\n<p><code>\nkeras &amp;lt;- import(\"keras\")\nkeras$applications$\n</code></p>\n\n<p>Using reticulate and completing with the tab after the $ of application. You need latest Keras for this (I did not succeed to do it on kaggle, I have the others models.).</p>",
          "rawMarkdown": "@kckamojjala also I think the following could work : \n\n```\n`tf&lt;-import(\"tensorflow\")\ntf$keras$applications$`\n```\n\nor\n\n```\nkeras &lt;- import(\"keras\")\nkeras$applications$\n```\n\nUsing reticulate and completing with the tab after the $ of application. You need latest Keras for this (I did not succeed to do it on kaggle, I have the others models.)."
        }
      ]
    },
    {
      "id": 920848,
      "postDate": "2020-07-08T20:57:31.370Z",
      "content": "<p>Hello Everyone,</p>\n\n<p>I have just started to dive into deep learning using R. For this competition, I have seen a lot of notebooks using efficientnet models in their implementations. I have been working with other pre-trained networks but not to good success and at the same time,  I am not able to load efficientnet in my R code.</p>\n\n<p>Currently, I am using Keras 2.2.5 and tensorflow 2.2.0 version. I googled for efficientnet examples in R as well but could not find any. I understand that most of the users here are python experts but could someone please let me know if I can load efficientnet models at all in R ?</p>\n\n<p>So far, I have installed the efficientnet 1.1.0 python package using pip but I am not able to import it into RStudio. When I try to install the same package via RStudio, it says \"package ‘efficientnet’ is not available (for R version 3.6.2)\"</p>\n\n<p>Any help is appreciated.</p>\n\n<p>Thanks\nKC</p>",
      "rawMarkdown": "Hello Everyone,\n\nI have just started to dive into deep learning using R. For this competition, I have seen a lot of notebooks using efficientnet models in their implementations. I have been working with other pre-trained networks but not to good success and at the same time,  I am not able to load efficientnet in my R code.\n\nCurrently, I am using Keras 2.2.5 and tensorflow 2.2.0 version. I googled for efficientnet examples in R as well but could not find any. I understand that most of the users here are python experts but could someone please let me know if I can load efficientnet models at all in R ?\n\nSo far, I have installed the efficientnet 1.1.0 python package using pip but I am not able to import it into RStudio. When I try to install the same package via RStudio, it says \"package ‘efficientnet’ is not available (for R version 3.6.2)\"\n\nAny help is appreciated.\n\nThanks\nKC\n\n",
      "votes": 1
    },
    {
      "id": 922586,
      "postDate": "2020-07-10T08:07:58.187Z",
      "content": "<p>It's 2020, I would throw RStudio where it belongs. In the bin.</p>",
      "rawMarkdown": "It's 2020, I would throw RStudio where it belongs. In the bin.",
      "votes": -4,
      "replies": [
        {
          "id": 922981,
          "postDate": "2020-07-10T13:12:26.130Z",
          "content": "<p>Well ... sometimes you need to ride a different bike to go someplace!!</p>",
          "rawMarkdown": "Well ... sometimes you need to ride a different bike to go someplace!!\n",
          "votes": 3
        },
        {
          "id": 923016,
          "postDate": "2020-07-10T13:37:51.150Z",
          "content": "<p><a href=\"/group16\">@group16</a> Don't brush off <strong>R</strong> just yet 😄 </p>\n\n<p>R is used by many statisticians and researchers because it is very easy to obtain statistical results faster. It is also used in University course work for statistical analysis and data processing. R also has very good visualizations and powerful packages.</p>\n\n<p>PS: It is presently the <a href=\"https://www.tiobe.com/tiobe-index/\">8th most used</a> programming language.</p>",
          "rawMarkdown": "@group16 Don't brush off **R** just yet 😄 \n\nR is used by many statisticians and researchers because it is very easy to obtain statistical results faster. It is also used in University course work for statistical analysis and data processing. R also has very good visualizations and powerful packages.\n\nPS: It is presently the [8th most used](https://www.tiobe.com/tiobe-index/) programming language.",
          "votes": 2
        },
        {
          "id": 923061,
          "postDate": "2020-07-10T14:04:41.163Z",
          "content": "<p>It was a bit of a joke :). But I would always recommend Python over R to someone that has to learn something. Of course, if you already know R it could still be useful.</p>\n\n<p>That said, there's literally no advantage of R over Python. None. Python has more libraries, runs faster, has more logical and consistent syntax (but that's a matter of personal preference), Python can be used in production and the functionality of R is a subset of that of Python (try making a larger DS project in R, or try making something not data-science related in R). It was nice when Jupyter notebooks did not exist, because you had a interactive environment.</p>",
          "rawMarkdown": "It was a bit of a joke :). But I would always recommend Python over R to someone that has to learn something. Of course, if you already know R it could still be useful.\n\nThat said, there's literally no advantage of R over Python. None. Python has more libraries, runs faster, has more logical and consistent syntax (but that's a matter of personal preference), Python can be used in production and the functionality of R is a subset of that of Python (try making a larger DS project in R, or try making something not data-science related in R). It was nice when Jupyter notebooks did not exist, because you had a interactive environment.",
          "votes": 2
        },
        {
          "id": 923117,
          "postDate": "2020-07-10T14:36:37.433Z",
          "content": "<p>As I said before, I know python is way better than R when it comes to data science especially the deep learning part of it because of some of  the reasons you mentioned 😊 . But for data visualizations and basic ML problems of my interest, I prefer R because its just my preference. I disagree about your statement that there's literally no advantage of R over Python and we can always debate about that but it was not the intent of this discussion.  My goal was to know whether I can use efficientnet in R or not :-). Thanks everyone for your comments though !</p>",
          "rawMarkdown": "As I said before, I know python is way better than R when it comes to data science especially the deep learning part of it because of some of  the reasons you mentioned 😊 . But for data visualizations and basic ML problems of my interest, I prefer R because its just my preference. I disagree about your statement that there's literally no advantage of R over Python and we can always debate about that but it was not the intent of this discussion.  My goal was to know whether I can use efficientnet in R or not :-). Thanks everyone for your comments though !",
          "votes": -1
        },
        {
          "id": 923969,
          "postDate": "2020-07-11T07:52:43.473Z",
          "content": "<p><a href=\"/group16\">@group16</a> I am curious, how do you put python in production for data science ? It is a real question, I did not use it since a moment, and R is quite easy to deploy, like with shiny. Django? For the possibility in data science I disagree, any time you need something a bit experimental in statistic or data science you have to use R. Same for basic machine learning. Scikit learn is just a best off of available machine learning practice. For example during a long time it was not possible to have the feature importance with a random forest on scikit. \nAt the notable exception of deep learning of course. Languages are tools. So we have to pick the best for a task. Anyway, from the R user perspective I would say that the principal problem to move from R to Python is ... the horrible dataframe in Python x) Really to me it is make most of the unattractivity of Python, you spent more time figure out how the hell panda works than training models.</p>",
          "rawMarkdown": "@group16 I am curious, how do you put python in production for data science ? It is a real question, I did not use it since a moment, and R is quite easy to deploy, like with shiny. Django? For the possibility in data science I disagree, any time you need something a bit experimental in statistic or data science you have to use R. Same for basic machine learning. Scikit learn is just a best off of available machine learning practice. For example during a long time it was not possible to have the feature importance with a random forest on scikit. \nAt the notable exception of deep learning of course. Languages are tools. So we have to pick the best for a task. Anyway, from the R user perspective I would say that the principal problem to move from R to Python is ... the horrible dataframe in Python x) Really to me it is make most of the unattractivity of Python, you spent more time figure out how the hell panda works than training models.",
          "votes": 1
        },
        {
          "id": 923985,
          "postDate": "2020-07-11T08:00:21.777Z",
          "content": "<blockquote>\n  <blockquote>\n    <p><a href=\"/group16\">@group16</a> I am curious, how do you put python in production for data science?</p>\n  </blockquote>\n</blockquote>\n\n<p>You can build a web application around it with flask, for example. The nice thing about Python is that you can do ANYTHING with it. Make a game, make a web-application, data science projects, ...</p>\n\n<blockquote>\n  <blockquote>\n    <p>For example during a long time it was not possible to have the feature importance with a random forest on scikit. </p>\n  </blockquote>\n</blockquote>\n\n<p>That could be back in the old days. But there were better ways of doing it (e.g. using Boruta) than what scikit-learn today provides. Today, the newest and state-of-the-art feature importance packages (shap, lime, ...) were first available in Python and are then ported to R. Pretty sure the support in R is a lot less.</p>\n\n<blockquote>\n  <blockquote>\n    <p>bit experimental in statistic or data science you have to use R</p>\n  </blockquote>\n</blockquote>\n\n<p>Definitely not. Could you name one thing that you can do in R but not in Python?</p>\n\n<blockquote>\n  <blockquote>\n    <p>the horrible dataframe in Python </p>\n  </blockquote>\n</blockquote>\n\n<p>I guess it is indeed what you are used to. I think the dataframe syntax of R is ugly and inconsistent (e.g. functions <code>is.na</code> vs <code>isNA</code>. I think pandas is great, but I can indeed imagine that if you are used to a certain paradigm, that it is very hard to switch.</p>",
          "rawMarkdown": "&gt;&gt; @group16 I am curious, how do you put python in production for data science?\n\nYou can build a web application around it with flask, for example. The nice thing about Python is that you can do ANYTHING with it. Make a game, make a web-application, data science projects, ...\n\n&gt;&gt; For example during a long time it was not possible to have the feature importance with a random forest on scikit. \n\nThat could be back in the old days. But there were better ways of doing it (e.g. using Boruta) than what scikit-learn today provides. Today, the newest and state-of-the-art feature importance packages (shap, lime, ...) were first available in Python and are then ported to R. Pretty sure the support in R is a lot less.\n\n&gt;&gt; bit experimental in statistic or data science you have to use R\n\nDefinitely not. Could you name one thing that you can do in R but not in Python?\n\n&gt;&gt; the horrible dataframe in Python \n\nI guess it is indeed what you are used to. I think the dataframe syntax of R is ugly and inconsistent (e.g. functions `is.na` vs `isNA`. I think pandas is great, but I can indeed imagine that if you are used to a certain paradigm, that it is very hard to switch.\n",
          "votes": -1
        },
        {
          "id": 924039,
          "postDate": "2020-07-11T08:19:41.987Z",
          "content": "<p>Well, that the same in Python, why it is .head() but .shape and not .shape() ? :p \nBut more seriously, my first competition on kaggle was one for a PhD class in computer science. I was with my \"Hands on machine learning with scikit learn ...\", and I spent a lot of time on the iloc errors of Pandas than tuning the rf. The R dataframes or datatables are far more intuitive to manipulate I think.</p>\n\n<p>It is fun, I though lime was only available in R. I did not know Python has access to package of data science outside of scikit.</p>\n\n<blockquote>\n  <p>Definitely not. Could you name one thing that you can do in R but not in Python?</p>\n</blockquote>\n\n<ul>\n<li>All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. </li>\n<li>Rules based approachs. A stupid example but I googled it quickly without results.</li>\n<li>All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.</li>\n</ul>\n\n<p>But it is tricky to reply ad hoc. A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.\nAnd someone doing Markov Statistics will never use Python.</p>\n\n<p>Anyway, I think the best for a data scientist is to not loose time. So as long as Keras in R is supported for example it is legit to continue with it if you know R.\nDo you have recommendation book for Python ML ? Outside of \"Hands on on machine learning with scikit learn and tensorflow\" second edition ? </p>",
          "rawMarkdown": "Well, that the same in Python, why it is .head() but .shape and not .shape() ? :p \nBut more seriously, my first competition on kaggle was one for a PhD class in computer science. I was with my \"Hands on machine learning with scikit learn ...\", and I spent a lot of time on the iloc errors of Pandas than tuning the rf. The R dataframes or datatables are far more intuitive to manipulate I think.\n\nIt is fun, I though lime was only available in R. I did not know Python has access to package of data science outside of scikit.\n\n&gt; Definitely not. Could you name one thing that you can do in R but not in Python?\n\n- All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. \n- Rules based approachs. A stupid example but I googled it quickly without results.\n- All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.\n\nBut it is tricky to reply ad hoc. A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.\nAnd someone doing Markov Statistics will never use Python.\n\nAnyway, I think the best for a data scientist is to not loose time. So as long as Keras in R is supported for example it is legit to continue with it if you know R.\nDo you have recommendation book for Python ML ? Outside of \"Hands on on machine learning with scikit learn and tensorflow\" second edition ? "
        },
        {
          "id": 924058,
          "postDate": "2020-07-11T08:32:51.730Z",
          "content": "<p>Agreed, it is not always very logical. <code>.shape</code> because it is a property, <code>.head()</code> when it is a function, but why shape is not a function or head not a property is something I cannot logically explain either. </p>\n\n<blockquote>\n  <blockquote>\n    <p>All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. </p>\n  </blockquote>\n</blockquote>\n\n<p>There's a LOT of bayesian libraries available: pyMC, STAN, ...</p>\n\n<blockquote>\n  <blockquote>\n    <p>Rules based approachs. A stupid example but I googled it quickly without results.</p>\n  </blockquote>\n</blockquote>\n\n<p>Not very supported indeed. But one example is using Orange (has a Python API). It has CN2 in there as a rule mining algorithm for example.</p>\n\n<blockquote>\n  <blockquote>\n    <p>All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.</p>\n  </blockquote>\n</blockquote>\n\n<p>These are all available under scipy.stats. I did some comparing between R and Python before, and R is more <strong>accurate</strong> regarding it's p-values for smaller samples. Python will always use an approximation (using some distribution) while R will calculate it exactly (by generating all possible permutations) for smaller samples.</p>\n\n<blockquote>\n  <blockquote>\n    <p>A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.</p>\n  </blockquote>\n</blockquote>\n\n<p>hmmlearn is a library in Python that would probably got you a gold medal in that competition :). There's pomegranate, Pyro, (and all of the aforementioned bayesian packages) ... for doing graphical/probabilistic modeling.</p>\n\n<p>Anyway, R is definitely not bad, and it used to have a LOT of advantages over Python back in the days, hence why many data scientists still use it. But if you would have to choose between one of the two today, then I cannot give an argument for choosing R.</p>\n\n<p>I don't really know any books to recommend, but <a href=\"/abhishek\">@abhishek</a> <a href=\"https://www.amazon.com/Approaching-Almost-Machine-Learning-Problem-ebook/dp/B089P13QHT\">recently published a hands-on book for hands-on ML with Python</a> :).</p>",
          "rawMarkdown": "Agreed, it is not always very logical. `.shape` because it is a property, `.head()` when it is a function, but why shape is not a function or head not a property is something I cannot logically explain either. \n\n&gt;&gt; All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. \n\nThere's a LOT of bayesian libraries available: pyMC, STAN, ...\n\n&gt;&gt; Rules based approachs. A stupid example but I googled it quickly without results.\n\nNot very supported indeed. But one example is using Orange (has a Python API). It has CN2 in there as a rule mining algorithm for example.\n\n&gt;&gt; All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.\n\nThese are all available under scipy.stats. I did some comparing between R and Python before, and R is more **accurate** regarding it's p-values for smaller samples. Python will always use an approximation (using some distribution) while R will calculate it exactly (by generating all possible permutations) for smaller samples.\n\n&gt;&gt; A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.\n\nhmmlearn is a library in Python that would probably got you a gold medal in that competition :). There's pomegranate, Pyro, (and all of the aforementioned bayesian packages) ... for doing graphical/probabilistic modeling.\n\n\nAnyway, R is definitely not bad, and it used to have a LOT of advantages over Python back in the days, hence why many data scientists still use it. But if you would have to choose between one of the two today, then I cannot give an argument for choosing R.\n\nI don't really know any books to recommend, but @abhishek [recently published a hands-on book for hands-on ML with Python](https://www.amazon.com/Approaching-Almost-Machine-Learning-Problem-ebook/dp/B089P13QHT) :)."
        },
        {
          "id": 924192,
          "postDate": "2020-07-11T10:11:17.233Z",
          "content": "<p>Ahh I did not know that Python as such library. Than beeing said, it seems hard to find them or having good doc.\nThank for the book :p it seems a bit old sadly. For exemple I have a book \"Practical data science with R\" that also describe other tools such as Rmarkdown or git/shiny, etc. If I was starting to code today in Python I would have no idea on how to create a library or spare time to prepare a presentation. I just know that the ref IDE is jupyter :p</p>",
          "rawMarkdown": "Ahh I did not know that Python as such library. Than beeing said, it seems hard to find them or having good doc.\nThank for the book :p it seems a bit old sadly. For exemple I have a book \"Practical data science with R\" that also describe other tools such as Rmarkdown or git/shiny, etc. If I was starting to code today in Python I would have no idea on how to create a library or spare time to prepare a presentation. I just know that the ref IDE is jupyter :p\n"
        }
      ]
    },
    {
      "id": 921571,
      "postDate": "2020-07-09T11:49:11.657Z",
      "content": "<p>AFAIK the R implementation is just wrapper on top of python Keras\nI'd strongly recommend using Python directly :)</p>",
      "rawMarkdown": "AFAIK the R implementation is just wrapper on top of python Keras\nI'd strongly recommend using Python directly :)",
      "votes": -1,
      "replies": [
        {
          "id": 921766,
          "postDate": "2020-07-09T14:33:25.823Z",
          "content": "<p>Thanks <a href=\"/hmendonca\">@hmendonca</a> . I agree with that but I was more curious to see why I cannot use efficientnet with as ease as I use othe pre-trained networks in R. May be this question should be directed to the Keras/RStudio group, however since there is a larger audience here, I thought somebody might be able to help clarify 😊 </p>",
          "rawMarkdown": "Thanks @hmendonca . I agree with that but I was more curious to see why I cannot use efficientnet with as ease as I use othe pre-trained networks in R. May be this question should be directed to the Keras/RStudio group, however since there is a larger audience here, I thought somebody might be able to help clarify 😊 ",
          "votes": 1
        },
        {
          "id": 921794,
          "postDate": "2020-07-09T15:08:32.343Z",
          "content": "<p>With R you could use the tfhub() package to import the efficientnet as a layer if I do not mistaken. </p>",
          "rawMarkdown": "With R you could use the tfhub() package to import the efficientnet as a layer if I do not mistaken. ",
          "votes": 1
        },
        {
          "id": 921797,
          "postDate": "2020-07-09T15:09:34.213Z",
          "content": "<p>But yes efficientnet and R is a pain, sometimes I wonder if I (we) should not end up just using python, as sad as it is :/</p>",
          "rawMarkdown": "But yes efficientnet and R is a pain, sometimes I wonder if I (we) should not end up just using python, as sad as it is :/",
          "votes": 1
        },
        {
          "id": 921813,
          "postDate": "2020-07-09T15:20:01.550Z",
          "content": "<p>RStudio Keras project already has 2 open tickets on this question:\n - <a href=\"https://github.com/rstudio/keras/issues/848\">https://github.com/rstudio/keras/issues/848</a>\n - <a href=\"https://github.com/rstudio/keras/issues/1075\">https://github.com/rstudio/keras/issues/1075</a></p>\n\n<p>Yes you are right, most people on Kaggle just use Python Jupyter notebooks.</p>",
          "rawMarkdown": "RStudio Keras project already has 2 open tickets on this question:\n - https://github.com/rstudio/keras/issues/848\n - https://github.com/rstudio/keras/issues/1075\n\nYes you are right, most people on Kaggle just use Python Jupyter notebooks.",
          "votes": 2
        },
        {
          "id": 921839,
          "postDate": "2020-07-09T15:43:28.460Z",
          "content": "<p>I will definitely look at tfhub() package.. its python world in deep learning for sure..but as I learn, R is in much better place that it was few years ago w.r.t deep learning. And as <a href=\"/sirishks\">@sirishks</a> mentioned above, I hope this is addressed soon.</p>",
          "rawMarkdown": "I will definitely look at tfhub() package.. its python world in deep learning for sure..but as I learn, R is in much better place that it was few years ago w.r.t deep learning. And as @sirishks mentioned above, I hope this is addressed soon.",
          "votes": 1
        },
        {
          "id": 921956,
          "postDate": "2020-07-09T17:20:30.937Z",
          "content": "<p>I have a failed attempt in my publics notebook.\nBasically you need TF2.2 to be able to train the efficient net (currently tf2.0 on kaggle). \nI do not know also of what is composed the layer exactly (I did not managed to pipe a global max pooling unlike what I have seen in different python tutorial).\nAlso be careful the tutorial of tfhub is maybe not up to date. I invite you to go check on the issue of the github repo ^^ I opened one... two days ago haha </p>",
          "rawMarkdown": "I have a failed attempt in my publics notebook.\nBasically you need TF2.2 to be able to train the efficient net (currently tf2.0 on kaggle). \nI do not know also of what is composed the layer exactly (I did not managed to pipe a global max pooling unlike what I have seen in different python tutorial).\nAlso be careful the tutorial of tfhub is maybe not up to date. I invite you to go check on the issue of the github repo ^^ I opened one... two days ago haha "
        },
        {
          "id": 922026,
          "postDate": "2020-07-09T18:38:21.067Z",
          "content": "<p>Yeah..I was looking at your notebooks. I have TF2.2 on my laptop so I can try using it. Will let you know the details if I succeed 😊 </p>",
          "rawMarkdown": "Yeah..I was looking at your notebooks. I have TF2.2 on my laptop so I can try using it. Will let you know the details if I succeed 😊 ",
          "votes": 1
        },
        {
          "id": 923182,
          "postDate": "2020-07-10T15:36:07.693Z",
          "content": "<p><a href=\"/kckamojjala\">@kckamojjala</a> thanks ! We have a long week end here in France and I have some credit on google cloud, hope I can run an efficient net for the PANDAS competition !</p>",
          "rawMarkdown": "@kckamojjala thanks ! We have a long week end here in France and I have some credit on google cloud, hope I can run an efficient net for the PANDAS competition !"
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 1008806,
      "author_name": "Etienne R",
      "author_url": "",
      "post_date": "2020-09-13T12:07:33.940000",
      "content": "<p>(shameless autopromition) It is a bit old, but here an efficientnet working on kaggle ;p <a href=\"https://www.kaggle.com/cdk292/efficientnet0-with-r\" target=\"_blank\">https://www.kaggle.com/cdk292/efficientnet0-with-r</a> </p>",
      "votes": 1,
      "replies": []
    },
    {
      "id": 922332,
      "author_name": "Marcelo Kittlein",
      "author_url": "",
      "post_date": "2020-07-10T03:10:50.683000",
      "content": "<p>I would try this</p>\n\n<p>library(reticulate)\npy_run_string(\"import efficientnet.keras as efn\")</p>\n\n<p>py_run_string(\"base_model = efn.EfficientNetB4(input_shape=(dim, dim, 3), weights=\\\"imagenet\\\", include_top=False, pooling=\\\"avg\\\"\")</p>\n\n<p>base_model=py$base_model</p>\n\n<p>and add layers to base_model</p>",
      "votes": 2,
      "replies": [
        {
          "id": 922352,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-10T03:38:21.610000",
          "content": "<p>Thanks a lot <a href=\"/kittlein\">@kittlein</a> . I will let you know how it goes !</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 926804,
          "author_name": "",
          "author_url": "",
          "post_date": "2020-07-13T02:35:30.397000",
          "content": "",
          "votes": 0,
          "replies": []
        },
        {
          "id": 926805,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-13T02:42:17.287000",
          "content": "<p><a href=\"/kittlein\">@kittlein</a> <a href=\"/cdk292\">@cdk292</a> Hi Marcelo, I was able to import EfficientNet in R using your code (thats an improvement for me 😊 ). However, when I tried to add layers to it, it started to throw me errors ( Error:TypeError: The added layer must be an instance of class Layer. Found:  )</p>\n\n<p>I will try to get that fixed and I was using the exact same syntax as for other pre-trained nets. A sample is shown below</p>\n\n<hr>\n\n<p>library(reticulate)\npy_run_string(\"import efficientnet.keras as efn\")\npy_run_string(\"base_model = efn.EfficientNetB4(input_shape=(224, 224, 3), weights=\\\"imagenet\\\", include_top=False, pooling=\\\"avg\\\")\")\nconv_base &lt;- py$base_model</p>\n\n<p>model&lt;- keras_model_sequential() %&gt;%\n  conv_base %&gt;% \n  layer_flatten() %&gt;%\n  layer_dense(units = 1, activation = \"sigmoid\")</p>\n\n<hr>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 930150,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-15T08:25:44.907000",
          "content": "<p><a href=\"/kckamojjala\">@kckamojjala</a> also I think the following could work : </p>\n\n<p><code>\n`tf&amp;lt;-import(\"tensorflow\")\ntf$keras$applications$`\n</code></p>\n\n<p>or</p>\n\n<p><code>\nkeras &amp;lt;- import(\"keras\")\nkeras$applications$\n</code></p>\n\n<p>Using reticulate and completing with the tab after the $ of application. You need latest Keras for this (I did not succeed to do it on kaggle, I have the others models.).</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 922586,
      "author_name": "Gilles Vandewiele",
      "author_url": "",
      "post_date": "2020-07-10T08:07:58.187000",
      "content": "<p>It's 2020, I would throw RStudio where it belongs. In the bin.</p>",
      "votes": -4,
      "replies": [
        {
          "id": 922981,
          "author_name": "Marcelo Kittlein",
          "author_url": "",
          "post_date": "2020-07-10T13:12:26.130000",
          "content": "<p>Well ... sometimes you need to ride a different bike to go someplace!!</p>",
          "votes": 3,
          "replies": []
        },
        {
          "id": 923016,
          "author_name": "Sirish Somanchi",
          "author_url": "",
          "post_date": "2020-07-10T13:37:51.150000",
          "content": "<p><a href=\"/group16\">@group16</a> Don't brush off <strong>R</strong> just yet 😄 </p>\n\n<p>R is used by many statisticians and researchers because it is very easy to obtain statistical results faster. It is also used in University course work for statistical analysis and data processing. R also has very good visualizations and powerful packages.</p>\n\n<p>PS: It is presently the <a href=\"https://www.tiobe.com/tiobe-index/\">8th most used</a> programming language.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 923061,
          "author_name": "Gilles Vandewiele",
          "author_url": "",
          "post_date": "2020-07-10T14:04:41.163000",
          "content": "<p>It was a bit of a joke :). But I would always recommend Python over R to someone that has to learn something. Of course, if you already know R it could still be useful.</p>\n\n<p>That said, there's literally no advantage of R over Python. None. Python has more libraries, runs faster, has more logical and consistent syntax (but that's a matter of personal preference), Python can be used in production and the functionality of R is a subset of that of Python (try making a larger DS project in R, or try making something not data-science related in R). It was nice when Jupyter notebooks did not exist, because you had a interactive environment.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 923117,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-10T14:36:37.433000",
          "content": "<p>As I said before, I know python is way better than R when it comes to data science especially the deep learning part of it because of some of  the reasons you mentioned 😊 . But for data visualizations and basic ML problems of my interest, I prefer R because its just my preference. I disagree about your statement that there's literally no advantage of R over Python and we can always debate about that but it was not the intent of this discussion.  My goal was to know whether I can use efficientnet in R or not :-). Thanks everyone for your comments though !</p>",
          "votes": -1,
          "replies": []
        },
        {
          "id": 923969,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-11T07:52:43.473000",
          "content": "<p><a href=\"/group16\">@group16</a> I am curious, how do you put python in production for data science ? It is a real question, I did not use it since a moment, and R is quite easy to deploy, like with shiny. Django? For the possibility in data science I disagree, any time you need something a bit experimental in statistic or data science you have to use R. Same for basic machine learning. Scikit learn is just a best off of available machine learning practice. For example during a long time it was not possible to have the feature importance with a random forest on scikit. \nAt the notable exception of deep learning of course. Languages are tools. So we have to pick the best for a task. Anyway, from the R user perspective I would say that the principal problem to move from R to Python is ... the horrible dataframe in Python x) Really to me it is make most of the unattractivity of Python, you spent more time figure out how the hell panda works than training models.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 923985,
          "author_name": "Gilles Vandewiele",
          "author_url": "",
          "post_date": "2020-07-11T08:00:21.777000",
          "content": "<blockquote>\n  <blockquote>\n    <p><a href=\"/group16\">@group16</a> I am curious, how do you put python in production for data science?</p>\n  </blockquote>\n</blockquote>\n\n<p>You can build a web application around it with flask, for example. The nice thing about Python is that you can do ANYTHING with it. Make a game, make a web-application, data science projects, ...</p>\n\n<blockquote>\n  <blockquote>\n    <p>For example during a long time it was not possible to have the feature importance with a random forest on scikit. </p>\n  </blockquote>\n</blockquote>\n\n<p>That could be back in the old days. But there were better ways of doing it (e.g. using Boruta) than what scikit-learn today provides. Today, the newest and state-of-the-art feature importance packages (shap, lime, ...) were first available in Python and are then ported to R. Pretty sure the support in R is a lot less.</p>\n\n<blockquote>\n  <blockquote>\n    <p>bit experimental in statistic or data science you have to use R</p>\n  </blockquote>\n</blockquote>\n\n<p>Definitely not. Could you name one thing that you can do in R but not in Python?</p>\n\n<blockquote>\n  <blockquote>\n    <p>the horrible dataframe in Python </p>\n  </blockquote>\n</blockquote>\n\n<p>I guess it is indeed what you are used to. I think the dataframe syntax of R is ugly and inconsistent (e.g. functions <code>is.na</code> vs <code>isNA</code>. I think pandas is great, but I can indeed imagine that if you are used to a certain paradigm, that it is very hard to switch.</p>",
          "votes": -1,
          "replies": []
        },
        {
          "id": 924039,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-11T08:19:41.987000",
          "content": "<p>Well, that the same in Python, why it is .head() but .shape and not .shape() ? :p \nBut more seriously, my first competition on kaggle was one for a PhD class in computer science. I was with my \"Hands on machine learning with scikit learn ...\", and I spent a lot of time on the iloc errors of Pandas than tuning the rf. The R dataframes or datatables are far more intuitive to manipulate I think.</p>\n\n<p>It is fun, I though lime was only available in R. I did not know Python has access to package of data science outside of scikit.</p>\n\n<blockquote>\n  <p>Definitely not. Could you name one thing that you can do in R but not in Python?</p>\n</blockquote>\n\n<ul>\n<li>All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. </li>\n<li>Rules based approachs. A stupid example but I googled it quickly without results.</li>\n<li>All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.</li>\n</ul>\n\n<p>But it is tricky to reply ad hoc. A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.\nAnd someone doing Markov Statistics will never use Python.</p>\n\n<p>Anyway, I think the best for a data scientist is to not loose time. So as long as Keras in R is supported for example it is legit to continue with it if you know R.\nDo you have recommendation book for Python ML ? Outside of \"Hands on on machine learning with scikit learn and tensorflow\" second edition ? </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 924058,
          "author_name": "Gilles Vandewiele",
          "author_url": "",
          "post_date": "2020-07-11T08:32:51.730000",
          "content": "<p>Agreed, it is not always very logical. <code>.shape</code> because it is a property, <code>.head()</code> when it is a function, but why shape is not a function or head not a property is something I cannot logically explain either. </p>\n\n<blockquote>\n  <blockquote>\n    <p>All bayesian stuff a bit experimental. Typically I don't see anything matching things like Bnlearn. </p>\n  </blockquote>\n</blockquote>\n\n<p>There's a LOT of bayesian libraries available: pyMC, STAN, ...</p>\n\n<blockquote>\n  <blockquote>\n    <p>Rules based approachs. A stupid example but I googled it quickly without results.</p>\n  </blockquote>\n</blockquote>\n\n<p>Not very supported indeed. But one example is using Orange (has a Python API). It has CN2 in there as a rule mining algorithm for example.</p>\n\n<blockquote>\n  <blockquote>\n    <p>All the statistics for biology like statistical tests (from basic t.test to advance hierarchical model like limma or negative binomial), but we are more in statistical than ML.</p>\n  </blockquote>\n</blockquote>\n\n<p>These are all available under scipy.stats. I did some comparing between R and Python before, and R is more <strong>accurate</strong> regarding it's p-values for smaller samples. Python will always use an approximation (using some distribution) while R will calculate it exactly (by generating all possible permutations) for smaller samples.</p>\n\n<blockquote>\n  <blockquote>\n    <p>A funny example is from the competition Ion Switching : someone reimplement the viterbi algorithm in Python. In R you have several implementation of it.</p>\n  </blockquote>\n</blockquote>\n\n<p>hmmlearn is a library in Python that would probably got you a gold medal in that competition :). There's pomegranate, Pyro, (and all of the aforementioned bayesian packages) ... for doing graphical/probabilistic modeling.</p>\n\n<p>Anyway, R is definitely not bad, and it used to have a LOT of advantages over Python back in the days, hence why many data scientists still use it. But if you would have to choose between one of the two today, then I cannot give an argument for choosing R.</p>\n\n<p>I don't really know any books to recommend, but <a href=\"/abhishek\">@abhishek</a> <a href=\"https://www.amazon.com/Approaching-Almost-Machine-Learning-Problem-ebook/dp/B089P13QHT\">recently published a hands-on book for hands-on ML with Python</a> :).</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 924192,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-11T10:11:17.233000",
          "content": "<p>Ahh I did not know that Python as such library. Than beeing said, it seems hard to find them or having good doc.\nThank for the book :p it seems a bit old sadly. For exemple I have a book \"Practical data science with R\" that also describe other tools such as Rmarkdown or git/shiny, etc. If I was starting to code today in Python I would have no idea on how to create a library or spare time to prepare a presentation. I just know that the ref IDE is jupyter :p</p>",
          "votes": 0,
          "replies": []
        }
      ]
    },
    {
      "id": 921571,
      "author_name": "Henrique Mendonça",
      "author_url": "",
      "post_date": "2020-07-09T11:49:11.657000",
      "content": "<p>AFAIK the R implementation is just wrapper on top of python Keras\nI'd strongly recommend using Python directly :)</p>",
      "votes": -1,
      "replies": [
        {
          "id": 921766,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-09T14:33:25.823000",
          "content": "<p>Thanks <a href=\"/hmendonca\">@hmendonca</a> . I agree with that but I was more curious to see why I cannot use efficientnet with as ease as I use othe pre-trained networks in R. May be this question should be directed to the Keras/RStudio group, however since there is a larger audience here, I thought somebody might be able to help clarify 😊 </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 921794,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-09T15:08:32.343000",
          "content": "<p>With R you could use the tfhub() package to import the efficientnet as a layer if I do not mistaken. </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 921797,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-09T15:09:34.213000",
          "content": "<p>But yes efficientnet and R is a pain, sometimes I wonder if I (we) should not end up just using python, as sad as it is :/</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 921813,
          "author_name": "Sirish Somanchi",
          "author_url": "",
          "post_date": "2020-07-09T15:20:01.550000",
          "content": "<p>RStudio Keras project already has 2 open tickets on this question:\n - <a href=\"https://github.com/rstudio/keras/issues/848\">https://github.com/rstudio/keras/issues/848</a>\n - <a href=\"https://github.com/rstudio/keras/issues/1075\">https://github.com/rstudio/keras/issues/1075</a></p>\n\n<p>Yes you are right, most people on Kaggle just use Python Jupyter notebooks.</p>",
          "votes": 2,
          "replies": []
        },
        {
          "id": 921839,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-09T15:43:28.460000",
          "content": "<p>I will definitely look at tfhub() package.. its python world in deep learning for sure..but as I learn, R is in much better place that it was few years ago w.r.t deep learning. And as <a href=\"/sirishks\">@sirishks</a> mentioned above, I hope this is addressed soon.</p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 921956,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-09T17:20:30.937000",
          "content": "<p>I have a failed attempt in my publics notebook.\nBasically you need TF2.2 to be able to train the efficient net (currently tf2.0 on kaggle). \nI do not know also of what is composed the layer exactly (I did not managed to pipe a global max pooling unlike what I have seen in different python tutorial).\nAlso be careful the tutorial of tfhub is maybe not up to date. I invite you to go check on the issue of the github repo ^^ I opened one... two days ago haha </p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 922026,
          "author_name": "KCKamojjala",
          "author_url": "",
          "post_date": "2020-07-09T18:38:21.067000",
          "content": "<p>Yeah..I was looking at your notebooks. I have TF2.2 on my laptop so I can try using it. Will let you know the details if I succeed 😊 </p>",
          "votes": 1,
          "replies": []
        },
        {
          "id": 923182,
          "author_name": "Etienne R",
          "author_url": "",
          "post_date": "2020-07-10T15:36:07.693000",
          "content": "<p><a href=\"/kckamojjala\">@kckamojjala</a> thanks ! We have a long week end here in France and I have some credit on google cloud, hope I can run an efficient net for the PANDAS competition !</p>",
          "votes": 0,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "1008806": "(shameless autopromition) It is a bit old, but here an efficientnet working on kaggle ;p https://www.kaggle.com/cdk292/efficientnet0-with-r ",
    "922332": "I would try this\n\nlibrary(reticulate)\npy\\_run\\_string(\"import efficientnet.keras as efn\")\n\npy\\_run\\_string(\"base\\_model = efn.EfficientNetB4(input\\_shape=(dim, dim, 3), weights=\\\"imagenet\\\", include\\_top=False, pooling=\\\"avg\\\"\")\n\nbase\\_model=py$base_model\n\nand add layers to base\\_model",
    "920848": "Hello Everyone,\n\nI have just started to dive into deep learning using R. For this competition, I have seen a lot of notebooks using efficientnet models in their implementations. I have been working with other pre-trained networks but not to good success and at the same time,  I am not able to load efficientnet in my R code.\n\nCurrently, I am using Keras 2.2.5 and tensorflow 2.2.0 version. I googled for efficientnet examples in R as well but could not find any. I understand that most of the users here are python experts but could someone please let me know if I can load efficientnet models at all in R ?\n\nSo far, I have installed the efficientnet 1.1.0 python package using pip but I am not able to import it into RStudio. When I try to install the same package via RStudio, it says \"package ‘efficientnet’ is not available (for R version 3.6.2)\"\n\nAny help is appreciated.\n\nThanks\nKC\n\n",
    "922586": "It's 2020, I would throw RStudio where it belongs. In the bin.",
    "921571": "AFAIK the R implementation is just wrapper on top of python Keras\nI'd strongly recommend using Python directly :)"
  }
}