예제 #1
0
 def __init__(self, dimc, act=nn.ELU()):
     super(MNISTConvEnc, self).__init__()
     self.enc = nn.Sequential(
         nn_.ResConv2d(1, 16, 3, 2, padding=1, activation=act), act,
         nn_.ResConv2d(16, 16, 3, 1, padding=1, activation=act), act,
         nn_.ResConv2d(16, 32, 3, 2, padding=1, activation=act), act,
         nn_.ResConv2d(32, 32, 3, 1, padding=1, activation=act), act,
         nn_.ResConv2d(32, 32, 3, 2, padding=1, activation=act), act,
         nn_.Reshape((-1, 32 * 4 * 4)), nn_.ResLinear(32 * 4 * 4, dimc),
         act)
예제 #2
0
 def __init__(self, dimz, dimc, act=nn.ELU()):
     super(MNISTConvDec, self).__init__()
     self.dec = nn.Sequential(
         nn_.ResLinear(dimz, dimc),
         act,
         nn_.ResLinear(dimc, 32 * 4 * 4),
         act,
         nn_.Reshape((-1, 32, 4, 4)),
         nn.Upsample(scale_factor=2, mode='bilinear'),
         nn_.ResConv2d(32, 32, 3, 1, padding=1, activation=act),
         act,
         nn_.ResConv2d(32, 32, 3, 1, padding=1, activation=act),
         act,
         nn_.slicer[:, :, :-1, :-1],
         nn.Upsample(scale_factor=2, mode='bilinear'),
         nn_.ResConv2d(32, 16, 3, 1, padding=1, activation=act),
         act,
         nn_.ResConv2d(16, 16, 3, 1, padding=1, activation=act),
         act,
         nn.Upsample(scale_factor=2, mode='bilinear'),
         nn_.ResConv2d(16, 1, 3, 1, padding=1, activation=act),
     )
예제 #3
0
파일: ex.py 프로젝트: piocalderon/Inveling
import nn

network = nn.Container()
network.add(nn.Reshape((1, 784)))
network.add(nn.Linear(784, 100))
network.add(nn.Sigmoid())
network.add(nn.Linear(100, 10))
network.add(nn.Sigmoid())
network.add(nn.MSE(), cost=True)
network.make()
예제 #4
0
파일: run.py 프로젝트: piocalderon/Inveling
    for filename, sents in data.iteritems():
        sent = choice(sents)
        mat = sent2matrix(sent)
        img = cv2.imread(path + filename)
        rs = cv2.resize(img, (100, 100)).reshape(
            (300, 100)).astype(theano.config.floatX)
        yield (mat, rs)


network = nn.Container()
# Encoder
network.add(nn.LSTM(dict_size, 300, 300))
network.add(nn.LSTM(300, 100, 100))
network.add(nn.LSTM(100, 100, 33))
# Decoder
network.add(nn.Reshape((1, 3, 11, 100)))
network.add(nn.SpatialConvolution((1, 3, 11, 100), (16, 3, 5, 5)))
network.add(nn.ReLU())
network.add(nn.SpatialMaxPooling((2, 2), 48))
network.add(nn.Reshape((2304, )))
network.add(nn.Linear(2304, 30000))
network.add(nn.Reshape((300, 100)))
network.add(nn.MSE(), cost=True)
print 'Network created'
print 'Compiling function'
network.make()
print 'Function created'

print 'In training'
k = 0
#n_train = 900