Hello @Dzandaa,
I presume that you intend to plot each channel of the activation map (not the features - neuronal weights).
To everyone else reading this post, if you do not know what an activation map is, you can have a look at
https://towardsdatascience.com/activation-maps-for-deep-learning-models-in-a-few-lines-of-code-ed9ced1e8d21 .
@Dzandaa, on your Python code, you are extracting a channel of the activation map: feature_img = result[0, :, :, i] .
As this has the "channel last" notation,
i is the channel.
This is what I would do in Pascal:
To produce an image, you need 3 channels (RGB). So, I would first produce a volume with 3 channels by copying the same channel with neuralvolume TVolume.CopyChannels(Original: TVolume; aChannels: array of integer) . In your code, it would look like this:
ImageVolume.CopyChannels(PredictedVolume, [i,i,i]);
As you have a ReLU, you won't have negative values for us to care about.
Then, you'll need to scale the volume to [0, 255]:
ImageVolume.NormalizeMax(255);
Then, to transform the
ImageVolume into an image, you can call either
SaveImageFromVolumeIntoFile or
LoadVolumeIntoImage from
neuraldatasets unit.
Alternatively, if your form has a TImage, you can call
LoadVolumeIntoTImage from the unit
neuralvolumev instead of calling SaveImageFromVolumeIntoFile or LoadVolumeIntoImage .
If, instead of plotting channels, you really intend to plot features, you can look at
https://sourceforge.net/p/cai/svncode/HEAD/tree/trunk/lazarus/experiments/visualCifar10BatchUpdate/ . In this source code example, the features of the first layer are plotted.
Does this reply solve the question?