faknow.model

faknow.model.model

class faknow.model.model.AbstractModel[source]

Bases: Module

abstract class for all models, every model should inherit it and implement the following methods: 1. calculate_loss 2. predict

__init__()[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

calculate_loss(data) Tensor | Dict[str, Tensor][source]

calculate loss

Parameters:

data – batch data

Returns:

loss or a dict of loss if there are multiple losses

Return type:

Union[Tensor, Dict[str, Tensor]]

predict(data_without_label) Tensor[source]

predict the probability of being fake news

Parameters:

data_without_label – batch data

Returns:

probability, shape=(batch_size, 2)

Return type:

Tensor

training: bool