This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square_gen(num): | |
for i in range(num): | |
yield i**2 | |
gen = square_gen(5) | |
for i in gen: | |
print(i) | |
for i in map(lambda x: x**2, range(5)): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
list(itertools.permutations('ABCD', 3)) | |
[('A', 'B', 'C'), | |
('A', 'B', 'D'), | |
('A', 'C', 'B'), | |
('A', 'C', 'D'), | |
('A', 'D', 'B'), | |
('A', 'D', 'C'), | |
('B', 'A', 'C'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import chainer | |
from chainer import cuda | |
from chainer import configuration | |
import chainer.functions as F | |
import chainer.links as L | |
from chainer.initializers import normal |