dgbpy.mlmodel_keras_dGB

Module Contents

Classes

dGB_UnetSeg

Abstract base class for user defined Keras machine learning models

dGB_UnetReg

Abstract base class for user defined Keras machine learning models

dGB_LeNet_Classifier

Abstract base class for user defined Keras machine learning models

dGB_LeNet_Regressor

Abstract base class for user defined Keras machine learning models

dGB_UNetSeg_VGG19

Abstract base class for user defined Keras machine learning models

dGB_UNetReg_VGG19

Abstract base class for user defined Keras machine learning models

Functions

_to_tensor(x, dtype)

root_mean_squared_error(y_true, y_pred)

getAdamOpt(learning_rate=0.0001)

cross_entropy_balanced(y_true, y_pred)

compile_model(model, nroutputs, isregression, isunet, learnrate)

dGBUNet(model_shape, nroutputs, predtype)

dGBLeNet(model_shape, nroutputs, predtype)

UNet_VGG19(model_shape, nroutputs, predtype)

dgbpy.mlmodel_keras_dGB._to_tensor(x, dtype)
dgbpy.mlmodel_keras_dGB.root_mean_squared_error(y_true, y_pred)
dgbpy.mlmodel_keras_dGB.getAdamOpt(learning_rate=0.0001)
dgbpy.mlmodel_keras_dGB.cross_entropy_balanced(y_true, y_pred)
dgbpy.mlmodel_keras_dGB.compile_model(model, nroutputs, isregression, isunet, learnrate)
dgbpy.mlmodel_keras_dGB.dGBUNet(model_shape, nroutputs, predtype)
class dgbpy.mlmodel_keras_dGB.dGB_UnetSeg

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB UNet Segmentation
uidescription = dGBs Unet image segmentation
predtype
outtype
dimtype
_make_model(self, model_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model

class dgbpy.mlmodel_keras_dGB.dGB_UnetReg

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB UNet Regression
uidescription = dGBs Unet image regression
predtype
outtype
dimtype
_make_model(self, model_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model

dgbpy.mlmodel_keras_dGB.dGBLeNet(model_shape, nroutputs, predtype)
class dgbpy.mlmodel_keras_dGB.dGB_LeNet_Classifier

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB LeNet classifier
uidescription = dGBs LeNet classifier Keras model in UserModel form
predtype
outtype
dimtype
_make_model(self, input_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model

class dgbpy.mlmodel_keras_dGB.dGB_LeNet_Regressor

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB LeNet regressor
uidescription = dGBs LeNet regressor Keras model in UserModel form
predtype
outtype
dimtype
_make_model(self, input_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model

dgbpy.mlmodel_keras_dGB.UNet_VGG19(model_shape, nroutputs, predtype)
class dgbpy.mlmodel_keras_dGB.dGB_UNetSeg_VGG19

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB UNet VGG19 Segmentation
uidescription = dGB UNet VGG19 Segmentation Keras model in UserModel form
predtype
outtype
dimtype
_make_model(self, input_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model

class dgbpy.mlmodel_keras_dGB.dGB_UNetReg_VGG19

Bases: dgbpy.keras_classes.UserModel

Abstract base class for user defined Keras machine learning models

This module provides support for users to add their own machine learning models to OpendTect.

It defines an abstract base class. Users derive there own model classes from this base class and implement the _make_model static method to define the structure of the keras model. The users model definition should be saved in a file name with “mlmodel_keras” as a prefix and be at the top level of the module search path so it can be discovered.

The “mlmodel_keras” class should also define some class variables describing the class: uiname : str - this is the name that will appear in the user interface uidescription : str - this is a short description which may be displayed to help the user predtype : DataPredType enum - type of prediction (must be member of DataPredType enum) outtype: OutputType enum - output shape type (OutputType.Pixel or OutputType.Image) dimtype : DimType enum - the input dimensions supported by model (must be member of DimType enum)

Examples

from dgbpy.keras_classes import UserModel, DataPredType, OutputType, DimType

class myModel(UserModel):

uiname = ‘mymodel’ uidescription = ‘short description of model’ predtype = DataPredType.Classification outtype = OutputType.Pixel dimtype = DimType.D3

def _make_model(self, input_shape, nroutputs, learnrate, data_format):

inputs = Input(input_shape) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(inputs) conv1 = Conv3D(2, (3,3,3), activation=’relu’, padding=’same’)(conv1) pool1 = MaxPooling3D(pool,size=(2,2,2))(conv1) … conv8 = Conv3D(1, (1,1,1,), activation=’sigmoid’)(conv7)

model = Model(inputs=[inputs], outputs=[conv8]) model.compile(optimizer = Adam(lr = 1e-4), loss = cross_entropy_balanced, metrics = [‘accuracy’]) return model

uiname = dGB UNet VGG19 Regression
uidescription = dGB UNet VGG19 Regression Keras model in UserModel form
predtype
outtype
dimtype
_make_model(self, model_shape, nroutputs, learnrate)

Abstract static method that defines a machine learning model.

Must be implemented in the user’s derived class

Parameters

input_shape : tuple Defines input data shape in the Keras default data_format for the current backend. For the TensorFlow backend the default data_format is ‘channels_last’ nroutputs : int (number of discrete classes for a classification) Number of outputs learnrate : float The step size applied at each iteration to move toward a minimum of the loss function

Returns

a compiled keras model