Permalink
Browse files

Fix importing/creation of NN impl

We need to specify nnlearner as a package. More subtly, because of TF
we can only run NNI in the same process in which it's created. This
means we need to wait until the run() method of the learner is called
before constructing the impl.
  • Loading branch information...
1 parent 34b504b commit 9224be50eee3cef679c4776d4268dff7f748a278 @charmasaur charmasaur committed Dec 2, 2016
Showing with 7 additions and 2 deletions.
  1. +1 −1 mloop/__init__.py
  2. +4 −1 mloop/learners.py
  3. +2 −0 mloop/nnlearner.py
View
@@ -13,4 +13,4 @@
import os
__version__= "2.1.1"
-__all__ = ['controllers','interfaces','launchers','learners','testing','utilities','visualizations','cmd']
+__all__ = ['controllers','interfaces','launchers','learners','nnlearner','testing','utilities','visualizations','cmd']
View
@@ -1587,7 +1587,6 @@ def __init__(self,
self.cost_has_noise = True
self.noise_level = 1
- self.neural_net_impl = NeuralNetImpl(self.num_params)
# TODO: What are these?
self.generation_num = 4
if (self.default_bad_cost is None) and (self.default_bad_uncertainty is None):
@@ -1799,6 +1798,10 @@ def run(self):
#current solution is to only log to the console for warning and above from a process
self.log = mp.log_to_stderr(logging.WARNING)
+ # The network needs to be created in the same process in which it runs
+ import mloop.nnlearner as mlnn
+ self.neural_net_impl = mlnn.NeuralNetImpl(self.num_params)
+
try:
while not self.end_event.is_set():
self.log.debug('Learner waiting for new params event')
View
@@ -7,6 +7,8 @@ class NeuralNetImpl():
'''
Neural network implementation.
+ This must run in the same process in which it's created.
+
Args:
num_params (int): The number of params.
'''

0 comments on commit 9224be5

Please sign in to comment.