Exemplo n.º 1
0
 def __init__(self,
              decay_step,
              decay_rate,
              stair_case=False,
              bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, decay_step, decay_rate,
                        stair_case)
Exemplo n.º 2
0
 def __init__(self,
              X,
              Y,
              model,
              criterion,
              end_trigger,
              batch_size,
              optim_method=None,
              cores=None,
              bigdl_type="float"):
     if not optim_method:
         optim_methods = {model.name(): SGD()}
     elif isinstance(optim_method, OptimMethod):
         optim_methods = {model.name(): optim_method}
     elif isinstance(optim_method, JavaObject):
         optim_methods = {
             model.name(): OptimMethod(optim_method, bigdl_type)
         }
     else:
         optim_methods = optim_method
     if cores is None:
         cores = multiprocessing.cpu_count()
     JavaValue.__init__(self, None, bigdl_type,
                        [JTensor.from_ndarray(X) for X in to_list(X)],
                        JTensor.from_ndarray(Y), model.value, criterion,
                        optim_methods, end_trigger, batch_size, cores)
Exemplo n.º 3
0
 def __init__(self, upper=None, lower=None, bigdl_type="float"):
     if upper is not None and lower is not None:
         upper = upper + 0.0
         lower = lower + 0.0
         JavaValue.__init__(self, None, bigdl_type, upper, lower)
     else:
         JavaValue.__init__(self, None, bigdl_type)
Exemplo n.º 4
0
    def __init__(self, min, bigdl_type="float"):
        """
        Create a MinLoss trigger.


        :param min: min loss
        """
        JavaValue.__init__(self, None, bigdl_type, min)
Exemplo n.º 5
0
    def __init__(self, max, bigdl_type="float"):
        """
        Create a MaxScore trigger.


        :param max: max score
        """
        JavaValue.__init__(self, None, bigdl_type, max)
Exemplo n.º 6
0
    def __init__(self, interval, bigdl_type="float"):
        """
        Create a SeveralIteration trigger.


        :param interval: interval is the "n" where an action is triggeredevery "n" iterations
        """
        JavaValue.__init__(self, None, bigdl_type, interval)
Exemplo n.º 7
0
    def __init__(self, max_epoch, bigdl_type="float"):
        """
        Create a MaxEpoch trigger.


        :param max_epoch: max_epoch
        """
        JavaValue.__init__(self, None, bigdl_type, max_epoch)
Exemplo n.º 8
0
    def __init__(self, max, bigdl_type="float"):
        """
        Create a MaxIteration trigger.


        :param max: max
        """
        JavaValue.__init__(self, None, bigdl_type, max)
Exemplo n.º 9
0
    def __init__(self, k=10, neg_num=100, bigdl_type="float"):
        """
        Create NDCG validation method.

        :param k: top k
        :param neg_num: number of negative items.
        """
        JavaValue.__init__(self, None, bigdl_type, k, neg_num)
Exemplo n.º 10
0
    def __init__(self, first, *other):
        """
        Create a Or trigger.


        :param first: first Trigger
        :param other: other Trigger
        """
        JavaValue.__init__(self, None, "float", first, list(other))
Exemplo n.º 11
0
    def __init__(self, log_dir, app_name, bigdl_type="float"):
        """
        Create a TrainSummary. Logs will be saved to log_dir/app_name/train.


        :param log_dir: the root dir to store the logs
        :param app_name: the application name
        """
        JavaValue.__init__(self, None, bigdl_type, log_dir, app_name)
Exemplo n.º 12
0
 def __init__(self,
              monitor,
              factor=0.1,
              patience=10,
              mode="min",
              epsilon=1e-4,
              cooldown=0,
              min_lr=0.0,
              bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, monitor, factor, patience,
                        mode, epsilon, cooldown, min_lr)
Exemplo n.º 13
0
    def __init__(self, log_dir, app_name, bigdl_type="float"):
        """
        Create a ValidationSummary. Logs will be saved to
        log_dir/app_name/train. By default, all ValidationMethod set into
        optimizer will be recorded and the recording interval is the same
        as trigger of ValidationMethod in the optimizer.


        :param log_dir: the root dir to store the logs
        :param app_name: the application name
        """
        JavaValue.__init__(self, None, bigdl_type, log_dir, app_name)
Exemplo n.º 14
0
 def __init__(self,
              classes,
              iou=0.5,
              use_voc2007=False,
              skip_class=-1,
              bigdl_type="float"):
     """
     :param classes: the number of classes
     :param iou: the IOU threshold
     :param use_voc2007: use validation method before voc2010 (i.e. voc2007)
     :param skip_class: skip calculation on a specific class (e.g. background)
     """
     JavaValue.__init__(self, None, bigdl_type, classes, iou, use_voc2007,
                        skip_class)
Exemplo n.º 15
0
 def __init__(self, jvalue, bigdl_type, *args):
     if (jvalue):
         assert (type(jvalue) == JavaObject)
         self.value = jvalue
     else:
         self.value = callBigDlFunc(bigdl_type,
                                    JavaValue.jvm_class_constructor(self),
                                    *args)
     self.bigdl_type = bigdl_type
Exemplo n.º 16
0
 def __init__(self, image=None, label=None, path=None, bigdl_type="float"):
     image_tensor = JTensor.from_ndarray(
         image) if image is not None else None
     label_tensor = JTensor.from_ndarray(
         label) if label is not None else None
     self.bigdl_type = bigdl_type
     self.value = callBigDlFunc(bigdl_type,
                                JavaValue.jvm_class_constructor(self),
                                image_tensor, label_tensor, path)
Exemplo n.º 17
0
    def __init__(self,
                 model,
                 training_rdd,
                 criterion,
                 end_trigger,
                 batch_size,
                 optim_method=None,
                 bigdl_type="float"):
        """
        Create an optimizer.


        :param model: the neural net model
        :param training_data: the training dataset
        :param criterion: the loss function
        :param optim_method: the algorithm to use for optimization,
           e.g. SGD, Adagrad, etc. If optim_method is None, the default algorithm is SGD.
        :param end_trigger: when to end the optimization
        :param batch_size: training batch size
        """
        if not optim_method:
            optim_methods = {model.name(): SGD()}
        elif isinstance(optim_method, OptimMethod):
            optim_methods = {model.name(): optim_method}
        elif isinstance(optim_method, JavaObject):
            optim_methods = {
                model.name(): OptimMethod(optim_method, bigdl_type)
            }
        else:
            optim_methods = optim_method
        if isinstance(training_rdd, RDD):
            JavaValue.__init__(self, None, bigdl_type, model.value,
                               training_rdd, criterion, optim_methods,
                               end_trigger, batch_size)
        elif isinstance(training_rdd, DataSet):
            self.bigdl_type = bigdl_type
            self.value = callBigDlFunc(self.bigdl_type,
                                       "createDistriOptimizerFromDataSet",
                                       model.value, training_rdd, criterion,
                                       optim_methods, end_trigger, batch_size)
Exemplo n.º 18
0
    def __init__(self,
                 image_list=None,
                 label_list=None,
                 jvalue=None,
                 bigdl_type="float"):
        assert jvalue or image_list, "jvalue and image_list cannot be None in the same time"
        if jvalue:
            self.value = jvalue
        else:
            # init from image ndarray list and label rdd(optional)
            image_tensor_list = map(lambda image: JTensor.from_ndarray(image),
                                    image_list)
            label_tensor_list = map(lambda label: JTensor.from_ndarray(label),
                                    label_list) if label_list else None
            self.value = callBigDlFunc(bigdl_type,
                                       JavaValue.jvm_class_constructor(self),
                                       image_tensor_list, label_tensor_list)

        self.bigdl_type = bigdl_type
Exemplo n.º 19
0
 def __init__(self, value, bigdl_type="float"):
     value = value + 0.0
     JavaValue.__init__(self, None, bigdl_type, value)
Exemplo n.º 20
0
 def __init__(self, mean, stdv, bigdl_type="float"):
     mean = mean + 0.0
     stdv = stdv + 0.0
     JavaValue.__init__(self, None, bigdl_type, mean, stdv)
Exemplo n.º 21
0
 def __init__(self, power, max_iteration, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, power, max_iteration)
Exemplo n.º 22
0
 def __init__(self, jvalue, bigdl_type, *args):
     self.value = jvalue if jvalue else callBigDlFunc(
         bigdl_type, JavaValue.jvm_class_constructor(self), *args)
     self.bigdl_type = bigdl_type
Exemplo n.º 23
0
 def __init__(self, metric_name, idx, count_idx):
     self.name = metric_name
     self.idx = idx
     self.count_idx = count_idx
     JavaValue.__init__(self, None, "float", metric_name, idx, count_idx)
Exemplo n.º 24
0
 def __init__(self, val_method, name, output_indices, label_indices):
     self.name = name
     self.val_method = val_method
     JavaValue.__init__(self, None, "float", val_method, name,
                        output_indices, label_indices)
Exemplo n.º 25
0
 def __init__(self, bigdl_type="float", *args):
     self.value = callBigDlFunc(bigdl_type,
                                JavaValue.jvm_class_constructor(self),
                                *args)
Exemplo n.º 26
0
 def __init__(self, iteration_per_epoch, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, iteration_per_epoch)
Exemplo n.º 27
0
 def __init__(self, k, classes, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, k, classes)
Exemplo n.º 28
0
 def __init__(self, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type)
Exemplo n.º 29
0
 def __init__(self, varianceNormAverage=True, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, varianceNormAverage)
Exemplo n.º 30
0
 def __init__(self, step_sizes, gamma, bigdl_type="float"):
     JavaValue.__init__(self, None, bigdl_type, step_sizes, gamma)