Class: OCI::GenerativeAi::Models::TrainingConfig
- Inherits:
-
Object
- Object
- OCI::GenerativeAi::Models::TrainingConfig
- Defined in:
- lib/oci/generative_ai/models/training_config.rb
Overview
The fine-tuning method and hyperparameters used for fine-tuning a custom model. This class has direct subclasses. If you are using this class as input to a service operations then you should favor using a subclass over the base class
Direct Known Subclasses
Constant Summary collapse
- TRAINING_CONFIG_TYPE_ENUM =
[ TRAINING_CONFIG_TYPE_TFEW_TRAINING_CONFIG = 'TFEW_TRAINING_CONFIG'.freeze, TRAINING_CONFIG_TYPE_VANILLA_TRAINING_CONFIG = 'VANILLA_TRAINING_CONFIG'.freeze, TRAINING_CONFIG_TYPE_UNKNOWN_ENUM_VALUE = 'UNKNOWN_ENUM_VALUE'.freeze ].freeze
Instance Attribute Summary collapse
-
#early_stopping_patience ⇒ Integer
Stop training if the loss metric does not improve beyond 'early_stopping_threshold' for this many times of evaluation.
-
#early_stopping_threshold ⇒ Float
How much the loss must improve to prevent early stopping.
-
#learning_rate ⇒ Float
The initial learning rate to be used during training.
-
#log_model_metrics_interval_in_steps ⇒ Integer
Determines how frequently to log model metrics.
-
#total_training_epochs ⇒ Integer
The maximum number of training epochs to run for.
-
#training_batch_size ⇒ Integer
The batch size used during training.
-
#training_config_type ⇒ String
[Required] The fine-tuning method for training a custom model.
Class Method Summary collapse
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.get_subtype(object_hash) ⇒ Object
Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.
-
.swagger_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks equality by comparing each attribute.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(other) ⇒ Boolean
-
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ TrainingConfig
constructor
Initializes the object.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
Constructor Details
#initialize(attributes = {}) ⇒ TrainingConfig
Initializes the object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 110 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } self.training_config_type = attributes[:'trainingConfigType'] if attributes[:'trainingConfigType'] self.training_config_type = "TFEW_TRAINING_CONFIG" if training_config_type.nil? && !attributes.key?(:'trainingConfigType') # rubocop:disable Style/StringLiterals raise 'You cannot provide both :trainingConfigType and :training_config_type' if attributes.key?(:'trainingConfigType') && attributes.key?(:'training_config_type') self.training_config_type = attributes[:'training_config_type'] if attributes[:'training_config_type'] self.training_config_type = "TFEW_TRAINING_CONFIG" if training_config_type.nil? && !attributes.key?(:'trainingConfigType') && !attributes.key?(:'training_config_type') # rubocop:disable Style/StringLiterals self.total_training_epochs = attributes[:'totalTrainingEpochs'] if attributes[:'totalTrainingEpochs'] raise 'You cannot provide both :totalTrainingEpochs and :total_training_epochs' if attributes.key?(:'totalTrainingEpochs') && attributes.key?(:'total_training_epochs') self.total_training_epochs = attributes[:'total_training_epochs'] if attributes[:'total_training_epochs'] self.learning_rate = attributes[:'learningRate'] if attributes[:'learningRate'] raise 'You cannot provide both :learningRate and :learning_rate' if attributes.key?(:'learningRate') && attributes.key?(:'learning_rate') self.learning_rate = attributes[:'learning_rate'] if attributes[:'learning_rate'] self.training_batch_size = attributes[:'trainingBatchSize'] if attributes[:'trainingBatchSize'] raise 'You cannot provide both :trainingBatchSize and :training_batch_size' if attributes.key?(:'trainingBatchSize') && attributes.key?(:'training_batch_size') self.training_batch_size = attributes[:'training_batch_size'] if attributes[:'training_batch_size'] self.early_stopping_patience = attributes[:'earlyStoppingPatience'] if attributes[:'earlyStoppingPatience'] raise 'You cannot provide both :earlyStoppingPatience and :early_stopping_patience' if attributes.key?(:'earlyStoppingPatience') && attributes.key?(:'early_stopping_patience') self.early_stopping_patience = attributes[:'early_stopping_patience'] if attributes[:'early_stopping_patience'] self.early_stopping_threshold = attributes[:'earlyStoppingThreshold'] if attributes[:'earlyStoppingThreshold'] raise 'You cannot provide both :earlyStoppingThreshold and :early_stopping_threshold' if attributes.key?(:'earlyStoppingThreshold') && attributes.key?(:'early_stopping_threshold') self.early_stopping_threshold = attributes[:'early_stopping_threshold'] if attributes[:'early_stopping_threshold'] self.log_model_metrics_interval_in_steps = attributes[:'logModelMetricsIntervalInSteps'] if attributes[:'logModelMetricsIntervalInSteps'] raise 'You cannot provide both :logModelMetricsIntervalInSteps and :log_model_metrics_interval_in_steps' if attributes.key?(:'logModelMetricsIntervalInSteps') && attributes.key?(:'log_model_metrics_interval_in_steps') self.log_model_metrics_interval_in_steps = attributes[:'log_model_metrics_interval_in_steps'] if attributes[:'log_model_metrics_interval_in_steps'] end |
Instance Attribute Details
#early_stopping_patience ⇒ Integer
Stop training if the loss metric does not improve beyond 'early_stopping_threshold' for this many times of evaluation.
38 39 40 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 38 def early_stopping_patience @early_stopping_patience end |
#early_stopping_threshold ⇒ Float
How much the loss must improve to prevent early stopping.
42 43 44 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 42 def early_stopping_threshold @early_stopping_threshold end |
#learning_rate ⇒ Float
The initial learning rate to be used during training
29 30 31 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 29 def learning_rate @learning_rate end |
#log_model_metrics_interval_in_steps ⇒ Integer
Determines how frequently to log model metrics.
Every step is logged for the first 20 steps and then follows this parameter for log frequency. Set to 0 to disable logging the model metrics.
49 50 51 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 49 def log_model_metrics_interval_in_steps @log_model_metrics_interval_in_steps end |
#total_training_epochs ⇒ Integer
The maximum number of training epochs to run for.
25 26 27 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 25 def total_training_epochs @total_training_epochs end |
#training_batch_size ⇒ Integer
The batch size used during training.
33 34 35 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 33 def training_batch_size @training_batch_size end |
#training_config_type ⇒ String
[Required] The fine-tuning method for training a custom model.
21 22 23 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 21 def training_config_type @training_config_type end |
Class Method Details
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 52 def self.attribute_map { # rubocop:disable Style/SymbolLiteral 'training_config_type': :'trainingConfigType', 'total_training_epochs': :'totalTrainingEpochs', 'learning_rate': :'learningRate', 'training_batch_size': :'trainingBatchSize', 'early_stopping_patience': :'earlyStoppingPatience', 'early_stopping_threshold': :'earlyStoppingThreshold', 'log_model_metrics_interval_in_steps': :'logModelMetricsIntervalInSteps' # rubocop:enable Style/SymbolLiteral } end |
.get_subtype(object_hash) ⇒ Object
Given the hash representation of a subtype of this class, use the info in the hash to return the class of the subtype.
86 87 88 89 90 91 92 93 94 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 86 def self.get_subtype(object_hash) type = object_hash[:'trainingConfigType'] # rubocop:disable Style/SymbolLiteral return 'OCI::GenerativeAi::Models::VanillaTrainingConfig' if type == 'VANILLA_TRAINING_CONFIG' return 'OCI::GenerativeAi::Models::TFewTrainingConfig' if type == 'TFEW_TRAINING_CONFIG' # TODO: Log a warning when the subtype is not found. 'OCI::GenerativeAi::Models::TrainingConfig' end |
.swagger_types ⇒ Object
Attribute type mapping.
67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 67 def self.swagger_types { # rubocop:disable Style/SymbolLiteral 'training_config_type': :'String', 'total_training_epochs': :'Integer', 'learning_rate': :'Float', 'training_batch_size': :'Integer', 'early_stopping_patience': :'Integer', 'early_stopping_threshold': :'Float', 'log_model_metrics_interval_in_steps': :'Integer' # rubocop:enable Style/SymbolLiteral } end |
Instance Method Details
#==(other) ⇒ Object
Checks equality by comparing each attribute.
181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 181 def ==(other) return true if equal?(other) self.class == other.class && training_config_type == other.training_config_type && total_training_epochs == other.total_training_epochs && learning_rate == other.learning_rate && training_batch_size == other.training_batch_size && early_stopping_patience == other.early_stopping_patience && early_stopping_threshold == other.early_stopping_threshold && log_model_metrics_interval_in_steps == other.log_model_metrics_interval_in_steps end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 217 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.swagger_types.each_pair do |key, type| if type =~ /^Array<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) public_method("#{key}=").call( attributes[self.class.attribute_map[key]] .map { |v| OCI::Internal::Util.convert_to_type(Regexp.last_match(1), v) } ) end elsif !attributes[self.class.attribute_map[key]].nil? public_method("#{key}=").call( OCI::Internal::Util.convert_to_type(type, attributes[self.class.attribute_map[key]]) ) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end |
#eql?(other) ⇒ Boolean
197 198 199 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 197 def eql?(other) self == other end |
#hash ⇒ Fixnum
Calculates hash code according to all attributes.
206 207 208 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 206 def hash [training_config_type, total_training_epochs, learning_rate, training_batch_size, early_stopping_patience, early_stopping_threshold, log_model_metrics_interval_in_steps].hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
250 251 252 253 254 255 256 257 258 259 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 250 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = public_method(attr).call next if value.nil? && !instance_variable_defined?("@#{attr}") hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
244 245 246 |
# File 'lib/oci/generative_ai/models/training_config.rb', line 244 def to_s to_hash.to_s end |