aspuru-guzik-group / ga Goto Github PK
View Code? Open in Web Editor NEWCode for the paper: Augmenting genetic algorithms with deep neural networks for exploring the chemical space
Code for the paper: Augmenting genetic algorithms with deep neural networks for exploring the chemical space
I am unable to resolve 'RuntimeError An attack has been made to start a new process before the current process has finished its bootstrapping phase.' Requesting assistance with this issue!
Hi all,
When I run the core_GA script with a list of 6 starting SELFiES, I appear to be running into a numpy operator issue when it tries to compute the fitness using the normalized values of logP, SAS and RingP. Was wondering if anyone ever ran into this before and whether it's an issue with my starting dataset or a newer version of a dependency?
### On generation 1 of 200
Traceback (most recent call last):
File "core_GA.py", line 130, in <module>
impose_time_adapted_pen = False
File "core_GA.py", line 55, in initiate_ga
image_dir, data_dir, max_fitness_collector, impose_time_adapted_pen)
File "/nfshomes/schithrananda/generative_ml_experiments/GA/generation_props.py", line 296, in obtain_fitness
disc_enc_type, generation_index, max_molecules_len, device, num_processors, writer, beta, data_dir, max_fitness_collector, impose_time_adapted_pen)
File "/nfshomes/schithrananda/generative_ml_experiments/GA/generation_props.py", line 164, in fitness
fitness = (logP_norm) - (SAS_norm) - (RingP_norm)
ValueError: operands could not be broadcast together with shapes (500,1) (0,1)
Beyond modifying the starting_selfies to use a custom one rather than a sample of ZINC - these are the settings I used:
# Initiate the Genetic Algorithm
smiles_all_counter = initiate_ga( num_generations = 200,
generation_size = 500,
starting_selfies = selfies_list, # pass reference selfies
max_molecules_len = 100, #changed to 100
disc_epochs_per_generation = 10,
disc_enc_type = 'properties_rdkit', # 'selfies' or 'smiles' or 'properties_rdkit'
disc_layers = [100, 10],
training_start_gen = 0, # generation index to start training discriminator
device = 'cpu',
# pass all penalties for now since I want to see ring size, synthesizability, drug-likeness and logP
properties_calc_ls = ['logP', 'SAS', 'QED' 'RingP'], # None: No properties ; 'logP', 'SAS', 'RingP', 'QED'
num_processors = multiprocessing.cpu_count(),
beta = beta,
max_fitness_collector = max_fitness_collector,
impose_time_adapted_pen = True
)
File "", line 1, in
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 125, in _main
prepare(preparation_data)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "/Users/opt/anaconda3/lib/python3.8/runpy.py", line 265, in run_path
return _run_module_code(code, init_globals, run_name,
File "/Users/opt/anaconda3/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/opt/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/Users/Workspace/GA-master/core_GA.py", line 4, in
import discriminator as D
File "/Users/Workspace/GA-master/discriminator.py", line 3, in
import evolution_functions as evo
File "/Users/Workspace/GA-master/evolution_functions.py", line 15, in
manager = multiprocessing.Manager()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/context.py", line 57, in Manager
m.start()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/managers.py", line 579, in start
self._process.start()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/context.py", line 284, in _Popen
return Popen(process_obj)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in init
super().init(process_obj)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/popen_fork.py", line 19, in init
self._launch(process_obj)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
Traceback (most recent call last):
File "core_GA.py", line 4, in
import discriminator as D
File "/Users/Workspace/repos/GA-master/discriminator.py", line 3, in
import evolution_functions as evo
File "/Users/Workspace/GA-master/evolution_functions.py", line 15, in
manager = multiprocessing.Manager()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/context.py", line 57, in Manager
m.start()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/managers.py", line 583, in start
self._address = reader.recv()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/connection.py", line 250, in recv
buf = self._recv_bytes()
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/connection.py", line 414, in _recv_bytes
buf = self._recv(4)
File "/Users/opt/anaconda3/lib/python3.8/multiprocessing/connection.py", line 383, in _recv
raise EOFError
EOFError
env: python3.8
## Impose the beta cuttoff! --------------------------
if impose_time_adapted_pen:
if generation_index > 100:
# Check if there is a stagnation for 5 generations! (检查了 max_fitness_collector 列表的最后五个元素是否都是相同的)
if len(set(max_fitness_collector[-5:])) == 1:
beta = 1000
print('Beta cutoff imposed index: ', generation_index)
f = open('{}/beta_change_log.txt'.format(data_dir), 'a+')
f.write(str(generation_index) + '\n')
f.close()
## beta cuttoff imposed! --------------------------
fitness = (beta * discriminator_predictions) + fitness
when the len(set(max_fitness_collector[-5:])) == 1:, then the fitness is very big, and get the order, But the change doesn't seem to be working? It simply increases the overall fitness of the population in this generation
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.