src.tastenet package

Submodules

src.tastenet.data_utils module

class src.tastenet.data_utils.TasteNetDataset(x, y, alt_spec_features, socio_demo_features)[source]

Bases: Dataset

src.tastenet.models module

class src.tastenet.models.Coral_layer(n_choices)[source]

Bases: Module

forward(x)[source]

return the output of Coral layer.

Parameters:

input (TensorVariable) – output of last residual layer.

class src.tastenet.models.MNL_layer(utility_structure, args)[source]

Bases: Module

forward(x, b=None)[source]

return the output of MNL complex layer.

Parameters:
  • x (TensorVariable) – output of last residual layer.

  • b (TensorVariable) – taste parameters.

class src.tastenet.models.TasteNet(args, num_alt_features, num_sd_chars, num_classes, num_latent_vals=None, utility_structure=None)[source]

Bases: Module

TasteNet-MNL model for Swissmetro

forward(x, z=None)[source]

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

l1_norm()[source]

L1 norm, not including bias

l2_norm()[source]

L2 norm, not including bias

lpmc_monotonic_constraints(b)[source]

Put transformation for the sake of constraints on the value of times This is only for the LPMC dataset and needs to be adapted for other datasets. b: taste parameters (N, 1): Individual taste parameters.

monotonic_constraints(b)[source]

Put transformation for the sake of constraints on the value of times This is only for the SwissMetro dataset and needs to be adapted for other datasets. b: taste parameters (N, 1): Individual taste parameters.

synthetic_monotonic_constraints(b)[source]

Put transformation for the sake of constraints on the value of times This is only for the synthetic dataset and needs to be adapted for other datasets. b: taste parameters (N, 1): Individual taste parameters.

class src.tastenet.models.TasteParams(layer_sizes, args, num_alt_features, num_classes, num_sd_chars, func_intercept=True, func_params=True)[source]

Bases: Module

Network for tastes

forward(z)[source]
Parameters:

z – (N,D) # batch size, input dimension

Returns:

(N,1) # taste parameters

Return type:

V

class src.tastenet.models.Utility(args, num_alt_features, num_classes, func_intercept=True, func_params=True, utility_structure=None)[source]

Bases: Module

forward(x, b=None)[source]
x: attributes of each alternative,

including the intercept (N,K) J alternatives, each have K attributes.

b: taste parameters (N, 1): Individual taste parameters.

src.tastenet.models.get_act(nl_func)[source]

Module contents