@classmethod<EOL><INDENT>def borrow_cached_network(klass, network_json, network_weights):<DEDENT>
assert network_weights is not None<EOL>key = klass.keras_network_cache_key(network_json)<EOL>if key not in klass.KERAS_MODELS_CACHE:<EOL><INDENT>import keras.models<EOL>network = keras.models.model_from_json(network_json)<EOL>existing_weights = None<EOL><DEDENT>else:<EOL><INDENT>(network, existing_weights) = klass.KERAS_MODELS_CACHE[key]<EOL><DEDENT>if existing_weights is not network_weights:<EOL><INDENT>network.set_weights(network_weights)<EOL>klass.KERAS_MODELS_CACHE[key] = (network, network_weights)<EOL><DEDENT>def throw(*args, **kwargs):<EOL><INDENT>raise NotImplementedError("<STR_LIT>")<EOL><DEDENT>network.fit = throw<EOL>return network<EOL>
Return a keras Model with the specified architecture and weights.
As an optimization, when possible this will reuse architectures from a
process-wide cache.

The returned object is "borrowed" in the sense that its weights can
change later after subsequent calls to this method from other objects.

If you're using this from a parallel implementation you'll need to
hold a lock while using the returned object.

Parameters
----------
network_json : string of JSON
network_weights : list of numpy.array

Returns
-------
keras.models.Model