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
Links are in the TODO details :P |
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
Related to: http://stackoverflow.com/questions/13056049/how-to-specify-the-from-tables-in-sqlalchemy-subqueries | |
1st Query: | |
EXPLAIN | |
SELECT MAX(d2.id) | |
FROM my_table d1 | |
JOIN my_table d2 | |
ON d2.id < d1.id | |
WHERE d1.id IN (111283470, 111283370, 111282470) |
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
from sqlalchemy import create_engine, or_ | |
from sqlalchemy import Column, Integer, MetaData, Table | |
from sqlalchemy.orm import sessionmaker | |
engine = create_engine('sqlite:///:memory:', echo=True) | |
meta = MetaData(bind=engine) | |
table = Table('tbl', meta, Column('id', Integer)) | |
session = sessionmaker(bind=engine)() | |
meta.create_all() |
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 theano | |
from theano import tensor | |
import pyutools.theano | |
import numpy | |
def post_inspect(index, node, thunk): | |
print 'INSPECTING:' | |
theano.printing.debugprint(node) | |
print 'Input shapes : %s' % ' / '.join([str(x[0].shape) for x in thunk.inputs]) | |
print 'Output shapes: %s' % ' / '.join([str(x[0].shape) for x in thunk.outputs]) |
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
# This is a simplified version of some code from Justin Bayer. | |
import scipy | |
import theano, theano.tensor as T | |
# Create parameters. | |
# | |
# Parameters are first allocated in a long consecutive array as a shared | |
# variable. Afterwards, reshaped subtensors are used in the expressions in. |
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 sys | |
import numpy | |
import theano | |
from theano import tensor | |
from theano.printing import debugprint | |
class MyOp(theano.gof.Op): |