| 277 | } |
| 278 | |
| 279 | func (m *TfkgModel) GetModelWeights() ([]*tf.Tensor, error) { |
| 280 | var variableOutputs []tf.Output |
| 281 | |
| 282 | for _, l := range m.layers { |
| 283 | for _, operation := range m.model.Graph.Operations() { |
| 284 | if strings.HasPrefix(operation.Name(), l.GetName()) && operation.Type() == "ReadVariableOp" { |
| 285 | variableOutputs = append(variableOutputs, m.model.Graph.Operation(operation.Name()).Output(0)) |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | results, e := m.model.Session.Run( |
| 291 | map[tf.Output]*tf.Tensor{}, |
| 292 | variableOutputs, |
| 293 | nil, |
| 294 | ) |
| 295 | if e != nil { |
| 296 | m.errorHandler.Error(e) |
| 297 | return nil, e |
| 298 | } |
| 299 | |
| 300 | return results, nil |
| 301 | } |
| 302 | |
| 303 | func (m *TfkgModel) GetLayerWeights(layerName string) ([]*tf.Tensor, error) { |
| 304 | var variableOutputs []tf.Output |