Python tutorials

TensorFlow: Save and Restore Models

Training a deep neural network model could take quite some time, depending on the complexity of your model, the amount of data you have, the hardware you’re running your models on, etc. On most of the occasions you’ll need to save your progress to a file, so in case of interruption (or a bug), you’ll be able to continue where you left off. Even more, after a successful training you’ll surely need to re-use the model’s learned parameters to make […]

Read more

Python Circular Imports

What is a Circular Dependency? A circular dependency occurs when two or more modules depend on each other. This is due to the fact that each module is defined in terms of the other (See Figure 1). For example: functionA(): functionB() And functionB(): functionA() The code above depicts a fairly obvious circular dependency. functionA() calls functionB(), thus depending on it, and functionB() calls functionA(). This type of circular dependency has some obvious problems, which we’ll describe a bit further in […]

Read more

Python Tutorial for Absolute Beginners

Python is one of the most widely used languages out there. Be it web development, machine learning and AI, or even micro-controller programming, Python has found its place just about everywhere. This article provides a brief introduction to Python for beginners to the language. The article is aimed at absolute beginners with no previous Python experience, although some previous programming knowledge will help, but is not necessarily required. I’ve found that the best way to learn is to try to […]

Read more

Append vs Extend in Python Lists

Adding Elements to a List Lists are one of the most useful data structures available in Python, or really any programming language, since they’re used in so many different algorithms and solutions. Once we have created a list, often times we may need to add new elements to it, whether it be at the end, beginning, or somewhere in between. Python offers us three different methods to do so. In this article I’ll be showing the differences between the append, […]

Read more

How to Copy a File in Python

Introduction When it comes to using Python to copy files, there are two main ways: using the shutil module or the os module. All of the os methods we show here are methods that allow us to execute shell commands from our Python code, which we’ll use to execute the copy command (Windows) or the cp command (Unix). You’ll notice that many of these methods, in both the shutil module and the os module, have very similar functionality (which shouldn’t […]

Read more

Modified Preorder Tree Traversal in Django

Introduction This article is an extension to a previous article titled, Recursive Model Relationships in Django, which demonstrated a way to utilize the bare-bones Django capabilities to define database-backed Classes that model a common use-case for a recursive relationship. The use case I intend to satisfy is the common relationship between employees and managers of employees, which are also employees themselves. Evaluating the Prior Implementation The prior article defined an Employee class that translates into a database table of the […]

Read more

Download Files with Python

Downloading files from different online resources is one of the most important and common programming tasks to perform on the web. The importance of file downloading can be highlighted by the fact that a huge number of successful applications allow users to download files. Here are just a few web application functions that require downloading files: File sharing Data mining Retrieving website code (CSS, JS, etc) Social media These are just a few of the applications that come to mind, […]

Read more

Python Exception Handling

This tutorial will give an introduction to what Python exceptions are, the most common types of exceptions, and how to handle raised exceptions with the try and except clauses. What is a Python Exception? A Python exception is a construct used to signal an important event, usually an error, that occurs when executing a program. An exception may cause the program to stop if it is not properly “caught” (i.e. handled correctly). If you think that your program might raise […]

Read more

Python Linked Lists

A linked list is one of the most common data structures used in computer science. It is also one of the simplest ones too, and is as well as fundamental to higher level structures like stacks, circular buffers, and queues. Generally speaking, a list is a collection of single data elements that are connected via references. C programmers know this as pointers. For example, a data element can consist of address data, geographical data, geometric data, routing information, or transaction […]

Read more

TensorFlow Neural Network Tutorial

TensorFlow is an open-source library for machine learning applications. It’s the Google Brain’s second generation system, after replacing the close-sourced DistBelief, and is used by Google for both research and production applications. TensorFlow applications can be written in a few languages: Python, Go, Java and C. This post is concerned about its Python version, and looks at the library’s installation, basic low-level components, and building a feed-forward neural network from scratch to perform learning on a real dataset. The training […]

Read more
1 165 166 167 168 169 176