You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some issues with the creation of a custom searcher. I am working with SNES for Neuroevolution: I am doing Regression with time series data. In particular I would like to use a custom weight initialization so that I can use as initial candidate solutions the weight initialization of the nn.Module I am using instead of the initial population that is created sampling from the uniform hyper-cube provided by problem.initial_bounds.
So I created a custom class DamageSNES, which inherits SNES, where I only change the __init__ method. In particular to create a new initial population I did the following:
First with self._population = self._problem.generate_batch(self._popsize) I created a SolutionBatch object (here we are however still using the default evotorch initialization based on initial_bounds)
Then I created the initial weights I want to give to the different individuals of the population (i.e. the different neural networks) using the _initialize_model_weights method. This method is contained in a custom version of the SupervisedNE problem class (see below). For the moment _intialize_model_weights is still a dumb function that simply sets all the weights to 1 but I used it just to see if the initial weights changed.
Then I exploited the set_values method to modify the values of self._population into the ones contained in initial_weights
Below I include the code I used, in particular:
DamageSNES → Custom searcher class where I tried to implement custom weight initialization
DamageSupervisedNE → Custom SupervisedNE class where I changed some of the basic methods of SupervisedNE and I added the _initialize_model_weights method to produce the initial weights.
DamageLogger → This is a custom logger I use to log some results on wandb. Here I simply added a print statement at the beginning to test the custom weight initialization, printing at every iteration the current population
The problem I am facing is that it seems that the custom weight initialization is not happening and evotorch is still using the default initialization based on initial_bounds. In fact the DamageLogger is printing out populations composed of random value between the extremes of initial_bounds I provide in input and it is not printing a population full of 1 as it should happen considering how I built the _initialize_model_weights function.
I don't know if custom weight initialization it's something that is possible to do in evotorch and weather there is a much easier way to do it than the approach I am trying to use.
The text was updated successfully, but these errors were encountered:
Details:
evotorch==0.5.1
torch==2.4.1
Description:
I am having some issues with the creation of a custom
searcher
. I am working withSNES
for Neuroevolution: I am doing Regression with time series data. In particular I would like to use a custom weight initialization so that I can use as initial candidate solutions the weight initialization of thenn.Module
I am using instead of the initial population that is created sampling from the uniform hyper-cube provided byproblem.initial_bounds
.So I created a custom class
DamageSNES
, which inheritsSNES
, where I only change the__init__
method. In particular to create a new initial population I did the following:self._population = self._problem.generate_batch(self._popsize)
I created aSolutionBatch
object (here we are however still using the defaultevotorch
initialization based oninitial_bounds
)_initialize_model_weights
method. This method is contained in a custom version of theSupervisedNE
problem class (see below). For the moment_intialize_model_weights
is still a dumb function that simply sets all the weights to 1 but I used it just to see if the initial weights changed.set_values
method to modify the values ofself._population
into the ones contained ininitial_weights
Below I include the code I used, in particular:
DamageSNES
→ Customsearcher
class where I tried to implement custom weight initializationDamageSupervisedNE
→ CustomSupervisedNE
class where I changed some of the basic methods ofSupervisedNE
and I added the_initialize_model_weights
method to produce the initial weights.DamageLogger
→ This is a custom logger I use to log some results onwandb
. Here I simply added aprint
statement at the beginning to test the custom weight initialization, printing at every iteration the current populationThe problem I am facing is that it seems that the custom weight initialization is not happening and
evotorch
is still using the default initialization based oninitial_bounds
. In fact theDamageLogger
is printing out populations composed of random value between the extremes ofinitial_bounds
I provide in input and it is not printing a population full of 1 as it should happen considering how I built the_initialize_model_weights
function.I don't know if custom weight initialization it's something that is possible to do in
evotorch
and weather there is a much easier way to do it than the approach I am trying to use.The text was updated successfully, but these errors were encountered: