Example #1
0
def __retrieve_np_exmachina():
    if not hasExmachina:
        raise RuntimeError("Requested npExmachina but ExMachina not compiled.")
    import numpy as np

    # Define the exmachina numpy constants
    return npConstants(useFortran=True, fp_dtype=np.float64, int_dtype=np.int64)
Example #2
0
def __retrieve_np_fastnet():
    if not hasFastnet:
        raise RuntimeError("Requested npFastnet but FastNet not compiled.")
    import numpy as np

    # Define the fastnet numpy constants
    return npConstants(useFortran=False, fp_dtype=np.float32, int_dtype=np.int32)
Example #3
0
 def numpy_wrapper(self):
     """
 Returns the api instance which is to be used to read the data
 """
     import numpy as np
     if self.core is TuningToolCores.ExMachina:
         # Define the exmachina numpy constants
         kwargs = {
             'useFortran': True,
             'fp_dtype': np.float64,
             'int_dtype': np.int64
         }
     elif self.core is TuningToolCores.FastNet:
         kwargs = {
             'useFortran': False,
             'fp_dtype': np.float32,
             'int_dtype': np.int32
         }
     elif self.core is TuningToolCores.keras:
         from keras.backend import backend
         if backend(
         ) == "theano":  # Theano copies data if input is not c-contiguous
             kwargs = {
                 'useFortran': False,
                 'fp_dtype': np.float32,
                 'int_dtype': np.int32
             }
         elif backend(
         ) == "tensorflow":  # tensorflow copies data if input is not fortran-contiguous
             kwargs = {
                 'useFortran': False,
                 'fp_dtype': np.float32,
                 'int_dtype': np.int32
             }
     return npConstants(**kwargs)