|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- using Tensorflow.Keras.ArgsDefinition;
- using Tensorflow.Keras.Losses;
- using Tensorflow.Keras.Metrics;
- using Tensorflow.Keras.Optimizers;
-
- namespace Tensorflow.Keras.Engine
- {
- public partial class Model
- {
- LossesContainer compiled_loss;
- MetricsContainer compiled_metrics;
-
- public void compile(IOptimizer optimizer,
- ILossFunc loss)
- {
- this.optimizer = optimizer ?? new RMSprop(new RMSpropArgs
- {
- });
-
- this.loss = loss ?? new MeanSquaredError();
-
- compiled_loss = new LossesContainer(this.loss, output_names: output_names);
- compiled_metrics = new MetricsContainer(new string[0], output_names: output_names);
-
- int experimental_steps_per_execution = 1;
- _configure_steps_per_execution(experimental_steps_per_execution);
-
- // Initialize cache attrs.
- _reset_compile_cache();
- _is_compiled = true;
- }
-
- public void compile(IOptimizer optimizer,
- ILossFunc loss,
- string[] metrics)
- {
- this.optimizer = optimizer ?? new RMSprop(new RMSpropArgs
- {
- });
-
- this.loss = loss ?? new MeanSquaredError();
-
- compiled_loss = new LossesContainer(this.loss, output_names: output_names);
- compiled_metrics = new MetricsContainer(metrics, output_names: output_names);
-
- int experimental_steps_per_execution = 1;
- _configure_steps_per_execution(experimental_steps_per_execution);
-
- // Initialize cache attrs.
- _reset_compile_cache();
- _is_compiled = true;
- }
-
- public void compile(string optimizer,
- string loss,
- string[] metrics)
- {
- this.optimizer = optimizer switch
- {
- "rmsprop" => new RMSprop(new RMSpropArgs
- {
-
- }),
- _ => new RMSprop(new RMSpropArgs
- {
- })
- };
-
- this.loss = loss switch
- {
- "mse" => new MeanSquaredError(),
- "mae" => new MeanAbsoluteError(),
- _ => new MeanSquaredError()
- };
-
- compiled_loss = new LossesContainer(this.loss, output_names: output_names);
- compiled_metrics = new MetricsContainer(metrics, output_names: output_names);
-
- int experimental_steps_per_execution = 1;
- _configure_steps_per_execution(experimental_steps_per_execution);
-
- // Initialize cache attrs.
- _reset_compile_cache();
- _is_compiled = true;
- }
-
- public void compile(IOptimizer optimizer,
- ILossFunc loss,
- IMetricFunc[] metrics)
- {
- this.optimizer = optimizer ?? new RMSprop(new RMSpropArgs
- {
- });
-
- this.loss = loss ?? new MeanSquaredError();
-
- compiled_loss = new LossesContainer(this.loss, output_names: output_names);
- compiled_metrics = new MetricsContainer(metrics, output_names: output_names);
-
- int experimental_steps_per_execution = 1;
- _configure_steps_per_execution(experimental_steps_per_execution);
-
- // Initialize cache attrs.
- _reset_compile_cache();
- _is_compiled = true;
- }
- }
- }
|