예제 #1
0
        public void Compile(StringOrInstance optimizer, string[] loss, string[] metrics = null, float[] loss_weights = null,
                            string sample_weight_mode = "None", string[] weighted_metrics = null, NDarray[] target_tensors = null)
        {
            var args = new Dictionary <string, object>();

            args["optimizer"]          = optimizer;
            args["loss"]               = loss;
            args["metrics"]            = metrics;
            args["loss_weights"]       = loss_weights;
            args["sample_weight_mode"] = sample_weight_mode;
            args["weighted_metrics"]   = weighted_metrics;
            args["target_tensors"]     = target_tensors;

            InvokeMethod("compile", args);
        }
예제 #2
0
        public void Compile(StringOrInstance optimizer, string loss, string[] metrics = null, float[] loss_weights = null,
                            string sample_weight_mode = "None", string[] weighted_metrics = null, NDarray[] target_tensors = null)
        {
            var args = new Dictionary <string, object>();

            args["optimizer"]          = optimizer.PyObject;
            args["loss"]               = loss;
            args["metrics"]            = metrics;
            args["loss_weights"]       = loss_weights;
            args["sample_weight_mode"] = sample_weight_mode;
            args["weighted_metrics"]   = weighted_metrics;
            args["target_tensors"]     = target_tensors;

            InvokeMethod("compile", args);

            //__self__.compile(optimizer: optimizer, loss: loss, metrics: metrics!=null ? metrics.ToList() : null, loss_weights: loss_weights, sample_weight_mode: sample_weight_mode,
            //            weighted_metrics: weighted_metrics, target_tensors: target_tensors);
        }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dense"/> class.
 /// </summary>
 /// <param name="units"> Positive integer, dimensionality of the output space.</param>
 /// <param name="activation"> Activation function to use (see activations). If you don't specify anything, no activation is applied (ie. "linear" activation: a(x) = x).</param>
 /// <param name="use_bias"> Boolean, whether the layer uses a bias vector.</param>
 /// <param name="kernel_initializer"> Initializer for the kernel weights matrix (see initializers).</param>
 /// <param name="bias_initializer"> Initializer for the bias vector (see initializers).</param>
 /// <param name="kernel_regularizer"> Regularizer function applied to the kernel weights matrix (see regularizer).</param>
 /// <param name="bias_regularizer"> Regularizer function applied to the bias vector (see regularizer).</param>
 /// <param name="activity_regularizer"> Regularizer function applied to the output of the layer (its "activation"). (see regularizer).</param>
 /// <param name="kernel_constraint"> Constraint function applied to the kernel weights matrix (see constraints).</param>
 /// <param name="bias_constraint"> Constraint function applied to the bias vector (see constraints).</param>
 /// <param name="input_shape">nD tensor with shape: (batch_size, ..., input_dim). The most common situation would be a 2D input with shape (batch_size, input_dim).</param>
 public Dense(int units, int?input_dim    = null, string activation = "", bool use_bias = true, StringOrInstance kernel_initializer = null,
              string bias_initializer     = "zeros", StringOrInstance kernel_regularizer = null, string bias_regularizer = "",
              string activity_regularizer = "", string kernel_constraint                 = "", string bias_constraint = "", Shape input_shape = null)
 {
     this["units"]                = units;
     this["input_dim"]            = input_dim;
     this["activation"]           = activation;
     this["use_bias"]             = use_bias;
     this["kernel_initializer"]   = kernel_initializer ?? "glorot_uniform";
     this["bias_initializer"]     = bias_initializer;
     this["kernel_regularizer"]   = kernel_regularizer;
     this["bias_regularizer"]     = bias_regularizer;
     this["activity_regularizer"] = activity_regularizer;
     this["kernel_constraint"]    = kernel_constraint;
     this["bias_constraint"]      = bias_constraint;
     Parameters["input_shape"]    = input_shape;
     PyInstance = Instance.keras.layers.Dense;
     Init();
 }