def get_weights_from_kmodel ( kmodel ) : layers_with_weights = [ layer for layer in kmodel . layers if layer . weights ] bweights = [ ] for klayer in layers_with_weights : # bws would be [weights, bias] or [weights] bws = WeightsConverter . get_bigdl_weights_from_klayer ( klayer ) for w in bws : bweights . append ( w ) return bweights
get weights from keras model python
Convert kmodel s weights to bigdl format . We are supposing the order is the same as the execution order . : param kmodel : keras model : return : list of ndarray
def get_weights_from_kmodel(kmodel):
        """
        Convert kmodel's weights to bigdl format.
        We are supposing the order is the same as the execution order.
        :param kmodel: keras model
        :return: list of ndarray
        """
        layers_with_weights = [layer for layer in kmodel.layers if layer.weights]
        bweights = []
        for klayer in layers_with_weights:
            # bws would be [weights, bias] or [weights]
            bws = WeightsConverter.get_bigdl_weights_from_klayer(klayer)
            for w in bws:
                bweights.append(w)
        return bweights