예제 #1
0
 def __init__(self, lr=0.01, epsilon=1e-8, decay=0., **kwargs):
     super(Adagrad, self).__init__(**kwargs)
     with K.name_scope(self.__class__.__name__):
         self.lr = K.variable(lr, name='lr')
         self.decay = K.variable(decay, name='decay')
         self.iterations = K.variable(0, dtype='int64', name='iterations')
     self.epsilon = epsilon
     self.initial_decay = decay
예제 #2
0
 def __init__(self, lr=0.01, momentum=0., decay=0., nesterov=False, **kwargs):
   super(SGD, self).__init__(**kwargs)
   with K.name_scope(self.__class__.__name__):
     self.iterations = K.variable(0, dtype='int64', name='iterations')
     self.lr = K.variable(lr, name='lr')
     self.momentum = K.variable(momentum, name='momentum')
     self.decay = K.variable(decay, name='decay')
   self.initial_decay = decay
   self.nesterov = nesterov
예제 #3
0
 def __init__(self, lr=0.01, momentum=0., decay=0., nesterov=False, **kwargs):
   super(SGD, self).__init__(**kwargs)
   with K.name_scope(self.__class__.__name__):
     self.iterations = K.variable(0, dtype='int64', name='iterations')
     self.lr = K.variable(lr, name='lr')
     self.momentum = K.variable(momentum, name='momentum')
     self.decay = K.variable(decay, name='decay')
   self.initial_decay = decay
   self.nesterov = nesterov
예제 #4
0
 def __init__(self, lr=0.01, epsilon=None, decay=0., **kwargs):
   super(Adagrad, self).__init__(**kwargs)
   with K.name_scope(self.__class__.__name__):
     self.lr = K.variable(lr, name='lr')
     self.decay = K.variable(decay, name='decay')
     self.iterations = K.variable(0, dtype='int64', name='iterations')
   if epsilon is None:
     epsilon = K.epsilon()
   self.epsilon = epsilon
   self.initial_decay = decay
 def __init__(self, lr=1.0, rho=0.95, epsilon=None, decay=0., **kwargs):
     super(Adadelta, self).__init__(**kwargs)
     with K.name_scope(self.__class__.__name__):
         self.lr = K.variable(lr, name='lr')
         self.decay = K.variable(decay, name='decay')
         self.iterations = K.variable(0, dtype='int64', name='iterations')
     if epsilon is None:
         epsilon = K.epsilon()
     self.rho = rho
     self.epsilon = epsilon
     self.initial_decay = decay
예제 #6
0
 def __init__(self,
              lr=0.002,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=1e-8,
              schedule_decay=0.004,
              **kwargs):
     super(Nadam, self).__init__(**kwargs)
     with K.name_scope(self.__class__.__name__):
         self.iterations = K.variable(0, dtype='int64', name='iterations')
         self.m_schedule = K.variable(1., name='m_schedule')
         self.lr = K.variable(lr, name='lr')
         self.beta_1 = K.variable(beta_1, name='beta_1')
         self.beta_2 = K.variable(beta_2, name='beta_2')
     self.epsilon = epsilon
     self.schedule_decay = schedule_decay
예제 #7
0
 def __init__(self,
              lr=0.002,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=1e-8,
              decay=0.,
              **kwargs):
     super(Adamax, self).__init__(**kwargs)
     with K.name_scope(self.__class__.__name__):
         self.iterations = K.variable(0, dtype='int64', name='iterations')
         self.lr = K.variable(lr, name='lr')
         self.beta_1 = K.variable(beta_1, name='beta_1')
         self.beta_2 = K.variable(beta_2, name='beta_2')
         self.decay = K.variable(decay, name='decay')
     self.epsilon = epsilon
     self.initial_decay = decay
예제 #8
0
 def __init__(self, optimizer):  # pylint: disable=super-init-not-called
     self.optimizer = optimizer
     with K.name_scope(self.__class__.__name__):
         if context.in_graph_mode():
             self.iterations = K.variable(0,
                                          dtype='int64',
                                          name='iterations')
예제 #9
0
 def __init__(self,
              lr=0.002,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=None,
              schedule_decay=0.004,
              **kwargs):
   super(Nadam, self).__init__(**kwargs)
   with K.name_scope(self.__class__.__name__):
     self.iterations = K.variable(0, dtype='int64', name='iterations')
     self.m_schedule = K.variable(1., name='m_schedule')
     self.lr = K.variable(lr, name='lr')
     self.beta_1 = K.variable(beta_1, name='beta_1')
     self.beta_2 = K.variable(beta_2, name='beta_2')
   if epsilon is None:
     epsilon = K.epsilon()
   self.epsilon = epsilon
   self.schedule_decay = schedule_decay
예제 #10
0
 def __init__(self,
              lr=0.002,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=None,
              decay=0.,
              **kwargs):
   super(Adamax, self).__init__(**kwargs)
   with K.name_scope(self.__class__.__name__):
     self.iterations = K.variable(0, dtype='int64', name='iterations')
     self.lr = K.variable(lr, name='lr')
     self.beta_1 = K.variable(beta_1, name='beta_1')
     self.beta_2 = K.variable(beta_2, name='beta_2')
     self.decay = K.variable(decay, name='decay')
   if epsilon is None:
     epsilon = K.epsilon()
   self.epsilon = epsilon
   self.initial_decay = decay
 def __init__(self,
              lr=0.001,
              beta_1=0.9,
              beta_2=0.999,
              epsilon=None,
              decay=0.,
              amsgrad=False,
              **kwargs):
     super(Adam, self).__init__(**kwargs)
     with K.name_scope(self.__class__.__name__):
         self.iterations = K.variable(0, dtype='int64', name='iterations')
         self.lr = K.variable(lr, name='lr')
         self.beta_1 = K.variable(beta_1, name='beta_1')
         self.beta_2 = K.variable(beta_2, name='beta_2')
         self.decay = K.variable(decay, name='decay')
     if epsilon is None:
         epsilon = K.epsilon()
     self.epsilon = epsilon
     self.initial_decay = decay
     self.amsgrad = amsgrad
                if mask[i, j] == 0.:
                    for k in range(3):
                        generated[i,j][k] = bg_color[k]

    return generated


def pooling_func(x):
    if pooltype == 1:
        return AveragePooling2D((2, 2), strides=(2, 2))(x)
    else:
        return MaxPooling2D((2, 2), strides = (2,2))(x)


# get tensor representations of our images
base_image = K.variable(preprocess_image(base_image_path, True, read_mode=read_mode))

style_reference_images = []
for style_path in style_image_paths:
    style_reference_images.append(K.variable(preprocess_image(style_path)))

# this will contain our generated image
combination_image = K.placeholder((1, img_width, img_height, 3))

image_tensors = [base_image]
for style_image_tensor in style_reference_images:
    image_tensors.append(style_image_tensor)
image_tensors.append(combination_image)

nb_tensors = len(image_tensors)
print("nb_tensors", nb_tensors)
예제 #13
0
 def __init__(self, optimizer):  # pylint: disable=super-init-not-called
   self.optimizer = optimizer
   with K.name_scope(self.__class__.__name__):
     self.iterations = K.variable(0, dtype='int64', name='iterations')