Using importTensorFlowNetwork does not load the model correctly
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to import the trained model for presentation in matlab APP,My tensorflow version is 2.3.1.Models are stored via saved_model
My code and error are as follows.
modelFolder='.\G_epoch40';
net = importTensorFlowNetwork(modelFolder,'OutputLayerType','regression')
Importing the saved model...
The function or variable 'Timesteps' is not recognized.
ERROR nnet.internal.cnn.keras.TranslatorForDAGInputLayer/translate (第 102 行)
if (LSpec.Has1DLayers && ~isnan(Timesteps))
ERROR nnet.internal.cnn.keras.LayerSpec/translateLayer (第 56 行)
NNTLayers = translate(this.Translator, this, TranslateWeights, TranslateTrainingParams, UserImageInputSize);
ERROR nnet.internal.cnn.keras.LayerSpec/translateDAGLayer (第 64 行)
NNTLayers = translateLayer(this, TranslateWeights, TranslateTrainingParams, UserImageInputSize);
ERROR nnet.internal.cnn.keras.AssembledModel>@(LSpec)translateDAGLayer(LSpec,AM.OutputTensors,AM.TrainingConfig,TranslateWeights,TranslateTrainingParams,UserImageInputSize,isRNN(AM)) (第 287 行)
NNTLayerGroups = cellfun(@(LSpec)translateDAGLayer(LSpec, AM.OutputTensors, AM.TrainingConfig, TranslateWeights,...
ERROR nnet.internal.cnn.keras.AssembledModel/translateDAGModel (第 287 行)
NNTLayerGroups = cellfun(@(LSpec)translateDAGLayer(LSpec, AM.OutputTensors, AM.TrainingConfig, TranslateWeights,...
ERROR nnet.internal.cnn.keras.AssembledModel/translateAssembledModel (第 64 行)
Layers = translateDAGModel(this, TranslateWeights, TranslateTrainingParams, UserImageInputSize);
ERROR nnet.internal.cnn.tensorflow.savedmodel.TFKerasManager (第 100 行)
LayersOrGraph = translateAssembledModel(obj.AM, obj.TrainingConfig, obj.AM.WeightsImported, false, ImageInputSize);
ERROR nnet.internal.cnn.tensorflow.savedmodel.TFSavedModel (第 35 行)
obj.KerasManager = savedmodel.TFKerasManager(smstruct.meta_graphs.object_graph_def, obj.SavedModelPath, kerasImporterOptions, importNetwork);
ERROR nnet.internal.cnn.tensorflow.importTensorFlowNetwork (第 19 行)
sm = savedmodel.TFSavedModel(path, options, true);
ERROR importTensorFlowNetwork (第 107 行)
Network = nnet.internal.cnn.tensorflow.importTensorFlowNetwork(modelFolder, varargin{:});
When I look at the translate function, the problem seems to be caused by 1Dcov with timestep. as follows.
Attached is the architecture of the model. This model is a generator in GAN, the input is noise of length 128 and the output is data of length 200 and number of channels 2.
Could anyone help me?
Thank you!
0 Kommentare
Antworten (1)
Sivylla Paraskevopoulou
am 31 Mai 2022
You can try to use the importTensorFlowLayers function. The importTensorFlowLayers function inserts placeholder layers in place of TensorFlow layers when the software cannot convert the TensorFlow layers to built-in MATLAB layers and cannot generate custom layers in place of the unsupported TensorFlow layers.
To find the names and indices of the placeholder layers in the layer graph, use the findPlaceholderLayers function. You can then replace a placeholder layer with a built-in MATLAB layer, custom layer or functionLayer. To replace a layer, use replaceLayer.
3 Kommentare
Sivylla Paraskevopoulou
am 1 Jun. 2022
Can you try to replace the variable Timesteps in your TensorFlow model with the actual value (for example, 2 or 10)? I think the issue might be that the import function doesn't know what Timesteps is, because you have defined it as a variable in your Python code.
Siehe auch
Kategorien
Mehr zu Image Data Workflows finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!