CategorizeAttributes returns attributes like train.*, validation.* and model.* to separated maps.
(trainStmt *ir.TrainStmt)
| 208 | |
| 209 | // CategorizeAttributes returns attributes like train.*, validation.* and model.* to separated maps. |
| 210 | func CategorizeAttributes(trainStmt *ir.TrainStmt) (trainParams, validateParams, modelParams map[string]interface{}) { |
| 211 | trainParams = make(map[string]interface{}) |
| 212 | validateParams = make(map[string]interface{}) |
| 213 | modelParams = make(map[string]interface{}) |
| 214 | |
| 215 | for attrKey, attr := range trainStmt.Attributes { |
| 216 | if strings.HasPrefix(attrKey, "train.") { |
| 217 | trainParams[strings.Replace(attrKey, "train.", "", 1)] = attr |
| 218 | } |
| 219 | if strings.HasPrefix(attrKey, "model.") { |
| 220 | modelParams[strings.Replace(attrKey, "model.", "", 1)] = attr |
| 221 | } |
| 222 | if strings.HasPrefix(attrKey, "validation.") { |
| 223 | validateParams[strings.Replace(attrKey, "validation.", "", 1)] = attr |
| 224 | } |
| 225 | } |
| 226 | return trainParams, validateParams, modelParams |
| 227 | } |
| 228 | |
| 229 | // DeriveFeatureColumnCodeAndFieldDescs generates tensorflow feature column code and field descs from IR. |
| 230 | func DeriveFeatureColumnCodeAndFieldDescs(trainStmt *ir.TrainStmt) (featureColumnsCode []string, fieldDescs map[string][]*ir.FieldDesc, err error) { |