# Path: scripts/keras/keras/layers/core.py
# class Layer(object):
#     def __init__(self):
#         self.params = []
# 
#     def connect(self, node):
#         self.previous = node
# 
#     def get_output(self, train):
#         raise NotImplementedError
# 
#     def get_input(self, train):
#         if hasattr(self, 'previous'):
#             return self.previous.get_output(train=train)
#         else:
#             return self.input
# 
#     def set_weights(self, weights):
#         for p, w in zip(self.params, weights):
#             p.set_value(floatX(w))
# 
#     def get_weights(self):
#         weights = []
#         for p in self.params:
#             weights.append(p.get_value())
#         return weights
# 
#     def get_config(self):
#         return {"name":self.__class__.__name__}


import theano
import theano.tensor as T
from theano.tensor.signal import downsample
from .. import activations, initializations
from ..utils.theano_utils import shared_zeros
from ..layers.core import Layer


# class Convolution1D(Layer): TODO

# class MaxPooling1D(Layer): TODO


class Convolution2D(Layer):
    def __init__(self, nb_filter, stack_size, nb_row, nb_col, 
        init='glorot_uniform', activation='linear', weights=None, 
        image_shape=None, border_mode='valid', subsample=(1,1)):
        super(Convolution2D,self).__init__()

        self.init = initializations.get(init)
        self.activation = activations.get(activation)
        self.subsample = subsample
        self.border_mode = border_mode
        self.image_shape = image_shape
        self.nb_filter = nb_filter
        self.stack_size = stack_size
        self.nb_row = nb_row
        self.nb_col = nb_col

        self.input = T.tensor4()
        self.W_shape = (nb_filter, stack_size, nb_row, nb_col)
        self.W = self.init(self.W_shape)
        self.b = shared_zeros((nb_filter,))

        self.params = [self.W, self.b]


# Path: scripts/keras/keras/layers/core.py
# class Layer(object):
#     def __init__(self):
#         self.params = []
# 
#     def connect(self, node):
#         self.previous = node
# 
#     def get_output(self, train):
#         raise NotImplementedError
# 
#     def get_input(self, train):
#         if hasattr(self, 'previous'):
#             return self.previous.get_output(train=train)
#         else:
#             return self.input
# 
#     def set_weights(self, weights):
#         for p, w in zip(self.params, weights):
#             p.set_value(floatX(w))
# 
#     def get_weights(self):
#         weights = []
#         for p in self.params:
#             weights.append(p.get_value())
#         return weights
# 
#     def get_config(self):
#         return {"name":self.__class__.__name__}


# Path: scripts/keras/keras/layers/convolutional.py
import theano
import theano.tensor as T
from theano.tensor.signal import downsample
from .. import activations, initializations
from ..utils.theano_utils import shared_zeros
from ..layers.core import Layer



# class Convolution1D(Layer): TODO

# class MaxPooling1D(Layer): TODO


class Convolution2D(Layer):
    def __init__(self, nb_filter, stack_size, nb_row, nb_col, 
        init='glorot_uniform', activation='linear', weights=None, 
        image_shape=None, border_mode='valid', subsample=(1,1)):
        super(Convolution2D,self).__init__()

        self.init = initializations.get(init)
        self.activation = activations.get(activation)
        self.subsample = subsample
        self.border_mode = border_mode
        self.image_shape = image_shape
        self.nb_filter = nb_filter
        self.stack_size = stack_size
        self.nb_row = nb_row
        self.nb_col = nb_col

        self.input = T.tensor4()
        self.W_shape = (nb_filter, stack_size, nb_row, nb_col)
        self.W = self.init(self.W_shape)
        self.b = shared_zeros((nb_filter,))

        self.params = [self.W, self.b]


        if weights is not None: