Ejemplo n.º 1
0
    def __init__(self, model, mode, port=4000, debug=True,
                 threaded=True, use_reloader=False):
        """Initializes and HTTP server from a serialized Keras model
        a parallelisation mode and a port to run the Flask application on. In
        hogwild mode no read- or write-locks will be acquired, in asynchronous
        mode this is the case.

        :param model: Serialized Keras model
        :param mode: parallelization mode, either `asynchronous` or `hogwild`
        :param port: int, port to run the application on
        :param debug: boolean, Flask debug mode
        :param threaded: boolean, Flask threaded application mode
        :param use_reloader: boolean, Flask `use_reloader` argument
        """

        self.master_network = dict_to_model(model)
        self.mode = mode
        self.master_url = None

        self.port = port

        if is_running_in_notebook():
            self.threaded = False
            self.use_reloader = False
            self.debug = False
        else:
            self.debug = debug
            self.threaded = threaded
            self.use_reloader = use_reloader

        self.lock = Lock()
        self.pickled_weights = None
        self.weights = self.master_network.get_weights()

        self.server = Process(target=self.start_flask_service)
Ejemplo n.º 2
0
def test_dict_to_model():
    model = Sequential()
    model.build((1, ))

    dict_model = serialization.model_to_dict(model)

    recovered = serialization.dict_to_model(dict_model)
    assert recovered.to_json() == model.to_json()
Ejemplo n.º 3
0
    def __init__(self, model, port=4000):
        """Initializes a Socket server instance from a serializer Keras model
        and a port to listen to.

        :param model: Serialized Keras model
        :param port: int, port to run the socket on
        """

        self.model = dict_to_model(model)
        self.port = port
        self.socket = None
        self.runs = False
        self.connections = []
        self.lock = Lock()
        self.thread = None
Ejemplo n.º 4
0
 def __init__(self, model, port, **kwargs):
     self.master_network = dict_to_model(model)
     self.port = port