Calculate power set (set of all subsets) in Python without recursion

If you want to calculate a set containing all subsets of set (also called power set) you could either choose an recursive approach or try this iterative approach which is faster than the recursive one.

def get_subsets(fullset):
  listrep = list(fullset)

  subsets = []
  for i in range(2**len(listrep)):
    subset = []
    for k in range(len(listrep)):			
      if i & 1<<k:

  return subsets

subsets = get_subsets(set([1,2,3,4]))

You can also find a shorter version at the end of the article, but to understand the principle the algorithm above is more suitable.

Read More

Image Style Transfer using Convolutional Neural Networks

There are many tasks in image processing that can be solved with Convolutional Neural Networks (CNNs). One of these tasks is called image style transfer. The goal of image style transfer is to apply the style of one image to the content of another image. This way you can create an drawing showing you in the style of Van Gogh, for example.

I am going to explain how style can be extracted from one image and transferred to the content of another image in this article.

Read More