TensorflowPredict

standard mode | Machine Learning category

Inputs

  • poolIn (pool) - the pool where to get the feature tensors

Outputs

  • poolOut (pool) - the pool where to store the output tensors

Parameters

  • graphFilename (string, default = "") :
    the name of the file from which to load the TensorFlow graph
  • inputs (vector_string) :
    will look for these namespaces in poolIn. Should match the names of the input nodes in the Tensorflow graph
  • isTraining (bool ∈ {true, false}, default = false) :
    run the model in training mode (normalized with statistics of the current batch) instead of inference mode (normalized with moving statistics). This only applies to some models
  • isTrainingName (string, default = "") :
    the name of an additional input node indicating whether the model is to be run in a training mode (for models with a training mode, leave it empty otherwise)
  • outputs (vector_string) :
    will save the tensors on the graph nodes named after outputs to the same namespaces in the output pool. Set the first element of this list as an empty array to print all the available nodes in the graph
  • savedModel (string, default = "") :
    the name of the TensorFlow SavedModel. Overrides parameter graphFilename
  • squeeze (bool ∈ {true, false}, default = true) :
    remove singleton dimensions of the inputs tensors. Does not apply to the batch dimension
  • tags (vector_string, default = ["serve"]) :
    the tags of the savedModel

Description

This algorithm runs a Tensorflow graph and stores the desired output tensors in a pool. The Tensorflow graph should be stored in Protocol Buffer (.pb) binary format [1] or as a SavedModel [2], and should contain both the architecture and the weights of the model. The parameter inputs should contain a list with the names of the input nodes that feed the model. The input Pool should contain the tensors corresponding to each input node stored using Essetia tensors. The pool namespace for each input tensor has to match the input node's name. In the same way, the outputs parameter should contain the names of the tensors to save. These tensors will be stored inside the output pool under a namespace that matches the tensor's name. TensorFlow nodes return tensors identified as nodeName:n, where n goes from 0 to the number of outputs of the node - 1. The first output tensor of a node can be referred implicitly (e.g., nodeName) or explicitly (e.g., nodeName:0), and the subsequent tensors require the specific index (e.g., nodeName:1, nodeName:2). In TensorFlow 2 SavedModels all the outputs of the model are contained in the PartitionedCall node (e.g., PartitionedCall:0, PartitionedCall:1). You can use TenorFlow's saved_model_cli to find the relation of outputs and PartitionedCall indices, for example:

>>>    saved_model_cli show --dir SavedModel/ --all
>>>    ...
>>>    The given SavedModel SignatureDef contains the following output(s):
>>>      outputs['activations'] tensor_info:
>>>          dtype: DT_FLOAT
>>>          shape: (1, 400)
>>>          name: PartitionedCall:0
>>>      outputs['embeddings'] tensor_info:
>>>          dtype: DT_FLOAT
>>>          shape: (1, 1280)
>>>          name: PartitionedCall:1
>>>    ...

To print a list with all the available nodes in the graph set the first element of outputs as an empty string (i.e., ""). This algorithm is a wrapper for the Tensorflow C API [3]. The first time it is configured with a non-empty graphFilename it will try to load the contained graph and to attach a Tensorflow session to it. The reset method deletes the current session (and the resources attached to it) and creates a new one relying on the available graph. By reconfiguring the algorithm the graph is reloaded and the reset method is called.

References:

[1] TensorFlow - An open source machine learning library for research and production. https://www.tensorflow.org/extend/tool_developers/#protocol_buffers

[2] TensorFlow - An open source machine learning library for research and production. https://www.tensorflow.org/guide/saved_model

[3] TensorFlow - An open source machine learning library for research and production. https://www.tensorflow.org/api_docs/cc/

See also

TensorflowPredict (streaming)

Standard algorithms

AfterMaxToBeforeMaxEnergyRatio | AllPass | AudioLoader | AudioOnsetsMarker | AudioWriter | AutoCorrelation | BFCC | BPF | BandPass | BandReject | BarkBands | BeatTrackerDegara | BeatTrackerMultiFeature | Beatogram | BeatsLoudness | BinaryOperator | BinaryOperatorStream | BpmHistogram | BpmHistogramDescriptors | BpmRubato | CartesianToPolar | CentralMoments | Centroid | ChordsDescriptors | ChordsDetection | ChordsDetectionBeats | ChromaCrossSimilarity | Chromagram | Chromaprinter | ClickDetector | Clipper | ConstantQ | CoverSongSimilarity | Crest | CrossCorrelation | CrossSimilarityMatrix | CubicSpline | DCRemoval | DCT | Danceability | Decrease | Derivative | DerivativeSFX | DiscontinuityDetector | Dissonance | DistributionShape | Duration | DynamicComplexity | ERBBands | EasyLoader | EffectiveDuration | Energy | EnergyBand | EnergyBandRatio | Entropy | Envelope | EqloudLoader | EqualLoudness | Extractor | FFT | FFTC | FadeDetection | FalseStereoDetector | Flatness | FlatnessDB | FlatnessSFX | Flux | FrameCutter | FrameGenerator | FrameToReal | FreesoundExtractor | FrequencyBands | GFCC | GaiaTransform | GapsDetector | GeometricMean | HFC | HPCP | HarmonicBpm | HarmonicMask | HarmonicModelAnal | HarmonicPeaks | HighPass | HighResolutionFeatures | Histogram | HprModelAnal | HpsModelAnal | HumDetector | IDCT | IFFT | IFFTC | IIR | Inharmonicity | InstantPower | Intensity | Key | KeyExtractor | LPC | Larm | Leq | LevelExtractor | LogAttackTime | LogSpectrum | LoopBpmConfidence | LoopBpmEstimator | Loudness | LoudnessEBUR128 | LoudnessVickers | LowLevelSpectralEqloudExtractor | LowLevelSpectralExtractor | LowPass | MFCC | Magnitude | MaxFilter | MaxMagFreq | MaxToTotal | Mean | Median | MedianFilter | MelBands | MetadataReader | Meter | MinMax | MinToTotal | MonoLoader | MonoMixer | MonoWriter | MovingAverage | MultiPitchKlapuri | MultiPitchMelodia | Multiplexer | MusicExtractor | MusicExtractorSVM | NNLSChroma | NSGConstantQ | NSGIConstantQ | NoiseAdder | NoiseBurstDetector | NoveltyCurve | NoveltyCurveFixedBpmEstimator | OddToEvenHarmonicEnergyRatio | OnsetDetection | OnsetDetectionGlobal | OnsetRate | Onsets | OverlapAdd | PCA | Panning | PeakDetection | PercivalBpmEstimator | PercivalEnhanceHarmonics | PercivalEvaluatePulseTrains | PitchCREPE | PitchContourSegmentation | PitchContours | PitchContoursMelody | PitchContoursMonoMelody | PitchContoursMultiMelody | PitchFilter | PitchMelodia | PitchSalience | PitchSalienceFunction | PitchSalienceFunctionPeaks | PitchYin | PitchYinFFT | PitchYinProbabilistic | PitchYinProbabilities | PitchYinProbabilitiesHMM | PolarToCartesian | PoolAggregator | PowerMean | PowerSpectrum | PredominantPitchMelodia | RMS | RawMoments | ReplayGain | Resample | ResampleFFT | RhythmDescriptors | RhythmExtractor | RhythmExtractor2013 | RhythmTransform | RollOff | SBic | SNR | SaturationDetector | Scale | SilenceRate | SineModelAnal | SineModelSynth | SineSubtraction | SingleBeatLoudness | SingleGaussian | Slicer | SpectralCentroidTime | SpectralComplexity | SpectralContrast | SpectralPeaks | SpectralWhitening | Spectrum | SpectrumCQ | SpectrumToCent | Spline | SprModelAnal | SprModelSynth | SpsModelAnal | SpsModelSynth | StartStopCut | StartStopSilence | StereoDemuxer | StereoMuxer | StereoTrimmer | StochasticModelAnal | StochasticModelSynth | StrongDecay | StrongPeak | SuperFluxExtractor | SuperFluxNovelty | SuperFluxPeaks | TCToTotal | TempoCNN | TempoScaleBands | TempoTap | TempoTapDegara | TempoTapMaxAgreement | TempoTapTicks | TensorNormalize | TensorTranspose | TensorflowInputFSDSINet | TensorflowInputMusiCNN | TensorflowInputTempoCNN | TensorflowInputVGGish | TensorflowPredict | TensorflowPredict2D | TensorflowPredictCREPE | TensorflowPredictEffnetDiscogs | TensorflowPredictFSDSINet | TensorflowPredictMAEST | TensorflowPredictMusiCNN | TensorflowPredictTempoCNN | TensorflowPredictVGGish | TonalExtractor | TonicIndianArtMusic | TriangularBands | TriangularBarkBands | Trimmer | Tristimulus | TruePeakDetector | TuningFrequency | TuningFrequencyExtractor | UnaryOperator | UnaryOperatorStream | Variance | Vibrato | Viterbi | WarpedAutoCorrelation | Welch | Windowing | YamlInput | YamlOutput | ZeroCrossingRate