Sign Up Now!

Sign up and get personalized intelligence briefing delivered daily.


Sign Up

Articles related to "function"


Deploying your first Deep Learning Model: MNIST in production environment

  • In this post i am going to write about how everyone who have completed MNIST can deploy there trained model as a beautiful web application in production environment using Django and Heroku.
  • After importing required libraries, lets write some helper functions to process our MNIST model in utils.py file.
  • Inside html file lets write some code to create canvas and submit the image drawn by user in that canvas.
  • After that lets write a code to submit those drawn lines to backend as base64 image file.
  • Now for last, lets add route to our fronted and write a function to serve our html file in our main app.
  • We are going to use Heroku to deploy our django project because it’s awesome and FREE!
  • To make our django project heroku ready, lets write a Procfile inside our root directory.

save | comments | report | share on


Create a Multipage Dash Application

  • Dash, a library built by Plotly, offers simple boiler plate code for developing interactive web applications in Python.
  • Dash bootstrap components divides the webpage into a grid, and is a useful tool for organizing the layout of a web application.
  • Because we are building a multipage application, we need to be able to import the layout into other files.
  • To do this, we will build a Homepage function that returns the entire layout for the page.
  • We’ll create a build_graph function that will accept a city from the dropdown menu and return a Plotly graph showing that city’s population trend.
  • IMPORTANT: In order to make our time series graph interactive, we have to create a callback function for the dropdown menu and output space.
  • Because there is no dropdown menu or output space in the homepage layout, we must change the configurations of our app.

save | comments | report | share on


Working with Errors in Go 1.13

  • This post describes the additions to the standard library that provide that support: three new functions in the errors package, and a new formatting verb for fmt.Errorf.
  • The most significant of these is a convention rather than a change: an error which contains another may implement an Unwrap method returning the underlying error.
  • When adding additional context to an error, either with fmt.Errorf or by implementing a custom type, you need to decide whether the new error should wrap the original.
  • There are other existing patterns for providing errors which can be semantically examined by the caller, such as directly returning a sentinel value, a specific type, or a value which can be examined with a predicate function.
  • If a function is defined as returning an error wrapping some sentinel or type, do not return the underlying error directly.

save | comments | report | share on


Use middleware in Next.js without custom server

  • APIs by exporting functions of two arguments req and res, which are extensions to Node's http.ClientRequest and http.ServerResponse.
  • The concept allowed us to augmented req and res by routing them through layers of a stack, which are known as middleware.
  • In those cases, the libraries actually return functions of (req, res, next) just like the way we approached above.
  • I will define handler function as the function of (req, res) that we need to export for API Routes.
  • Looking at the function withDatabase, it accepts an argument called handler, our original function.
  • Now that we have augmented req, we want to route it through our original handler.
  • Looking at return handler(req, res);, we are calling the original handler function we retrieve as an argument with the augmented req and (eh, unchanged) res.

save | comments | report | share on


Common Node.js mistakes in Lambda

  • I have helped quite a few clients with their Node.js serverless projects.
  • In doing so I have seen some recurring mistakes around async/await.
  • Before Node8, bluebird filled a massive gap.
  • It provided the utility to convert callback-based functions to promise-based.
  • But Node8's built-in util module has filled that gap with the promisify function.
  • No need to use bluebird anymore.
  • That's one less dependency, which helps reduce the cold start time for our functions.
  • This function is easy to follow, but it's hardly optimal.
  • teamModel.fetch doesn't depend on the result of fixtureModel.fetchAll, so they should run concurrently.
  • In this version, both fixtureModel.fetchAll and teamModel.fetch are started concurrently.
  • In this case, teamModel.fetch is called concurrently and can significantly improve execution time.
  • For now, just remember to avoid using async/await inside a forEach!
  • That's it, 5 common mistakes to avoid when working with Node.js in Lambda.

save | comments | report | share on


Clojure(Script)'s Sequence Abstraction

  • You can imagine map as walking over a sequence, and as it comes to each element, it takes that element, passes it through a function, and puts the result into a new sequence.
  • In general, map takes some function, f, and some sequence and returns a new sequence whose elements are the result of applying f to each element in the original sequence.
  • On the next line, we use the assoc function to create a new map that is like cart-item but with the addition of one more entry whose key is :sales-tax and whose value is (* price tax-rate).
  • We pass assoc a collection (in this case, cart-item), the key that we wish to set, and the value to set it to, and the result is a new collection with the appropriate entry added or updated.

save | comments | report | share on


Deploying your first Deep Learning Model: MNIST in production environment

  • In this post i am going to write about how everyone who have completed MNIST can deploy there trained model as a beautiful web application in production environment using Django and Heroku.
  • After importing required libraries, lets write some helper functions to process our MNIST model in utils.py file.
  • Inside html file lets write some code to create canvas and submit the image drawn by user in that canvas.
  • After that lets write a code to submit those drawn lines to backend as base64 image file.
  • Now for last, lets add route to our fronted and write a function to serve our html file in our main app.
  • We are going to use Heroku to deploy our django project because it’s awesome and FREE!
  • To make our django project heroku ready, lets write a Procfile inside our root directory.

save | comments | report | share on


Create a Multipage Dash Application

  • Dash, a library built by Plotly, offers simple boiler plate code for developing interactive web applications in Python.
  • Dash bootstrap components divides the webpage into a grid, and is a useful tool for organizing the layout of a web application.
  • Because we are building a multipage application, we need to be able to import the layout into other files.
  • To do this, we will build a Homepage function that returns the entire layout for the page.
  • We’ll create a build_graph function that will accept a city from the dropdown menu and return a Plotly graph showing that city’s population trend.
  • IMPORTANT: In order to make our time series graph interactive, we have to create a callback function for the dropdown menu and output space.
  • Because there is no dropdown menu or output space in the homepage layout, we must change the configurations of our app.

save | comments | report | share on


Deploying your first Deep Learning Model: MNIST in production environment

  • In this post i am going to write about how everyone who have completed MNIST can deploy there trained model as a beautiful web application in production environment using Django and Heroku.
  • After importing required libraries, lets write some helper functions to process our MNIST model in utils.py file.
  • Inside html file lets write some code to create canvas and submit the image drawn by user in that canvas.
  • After that lets write a code to submit those drawn lines to backend as base64 image file.
  • Now for last, lets add route to our fronted and write a function to serve our html file in our main app.
  • We are going to use Heroku to deploy our django project because it’s awesome and FREE!
  • To make our django project heroku ready, lets write a Procfile inside our root directory.

save | comments | report | share on


Python eval() built-in-function

  • Let us understand the eval() built-in-function in python.
  • This would be a short article about eval function in python, wherein I would be explaining to you about eval function, its syntax, and few questions that are often asked in interviews so that you clearly understand it and answer those questions in ease.
  • In simple words, the eval function evaluates the “String” like a python expression and returns the result as an integer.
  • See like I said I entered an integer 10+ 10 where I was expecting a result of 20 (10 + 10) but the input method returned a string of the same input entered.
  • In the case of eval, it returned the evaluated expression 20 in the form of an integer given the string as input.
  • See like I said if you give the input as a string and eval function evaluates the expression and returns the result as an integer.

save | comments | report | share on