Skip to content

ModuleAttributeError: 'MLP' object has no attribute 'DL' #1

@vishyML

Description

@vishyML

Hi, I tried running theory_exp.py . I get the following error when trying to to collapse the net to symbolic expression. It will be great help if you can help me resolve it.

Thank you,
Vishy.

================================================
Simplifying mode: to_symbolic for model_0

original_loss: 0.0010860880138352513
{'loss': 0.00270480802282691, 'DL': 2413.6943754734334, 'model_DL': 206.7324614109332, 'data_DL': 2206.9619140625}

ModuleAttributeError Traceback (most recent call last)
in
359
360 # To symbolic:
--> 361 loss_record = T.pred_nets.simplify(X_train, y_train, valid_onehot, "to_symbolic", simplify_criteria = simplify_criteria, validation_data = validation_pred_nets, is_Lagrangian = is_Lagrangian)
362 T.pred_nets.get_sympy_expression()
363 record_data(info_dict_single["data_record_simplification-model"], [T.get_losses(X_test, y_test, **kwargs), loss_record, T.pred_nets.model_dict, "after_to_symbolic_and_snapping"], ["all_losses_dict", "loss_record", "pred_nets_model_dict", "event"])

~\AI_physicist\pytorch_net\net.py in simplify(self, X, y, idx, mode, validation_data, isplot, **kwargs)
2548 print("The {0}'th model has no corresponding data to simplify with, skip.".format(i))
2549 else:
-> 2550 new_model, loss_dict["model_{0}".format(i)] = simplify(model, X_chosen, y_chosen, mode = mode, validation_data = validation_data_chosen, isplot = isplot, target_name = "model_{0}".format(i), **kwargs)
2551 setattr(self, "model_{0}".format(i), new_model)
2552 return loss_dict

~\AI_physicist\pytorch_net\net.py in simplify(model, X, y, mode, isplot, target_name, validation_data, **kwargs)
1317 # Calculate the loss again:
1318 if X is not None:
-> 1319 criteria_new, criteria_result_new = get_criteria_value(model, X, y, criteria_type = simplify_criteria[0], criterion = criterion, **kwargs)
1320 if verbose >= 1:
1321 print("Prev_loss: {0}, new loss: {1}\tprev_DL: {2:.9f}, new DL: {3:.9f}".format(

~\AI_physicist\pytorch_net\util.py in get_criteria_value(model, X, y, criteria_type, criterion, **kwargs)
412 if not isinstance(model, list):
413 model = [model]
--> 414 model_DL = np.sum([model_ele.DL for model_ele in model])
415 DL = data_DL + model_DL
416 result["DL"] = DL

~\AI_physicist\pytorch_net\util.py in (.0)
412 if not isinstance(model, list):
413 model = [model]
--> 414 model_DL = np.sum([model_ele.DL for model_ele in model])
415 DL = data_DL + model_DL
416 result["DL"] = DL

c:\users\vkswa\appdata\local\programs\python\python38\lib\site-packages\torch\nn\modules\module.py in getattr(self, name)
776 if name in modules:
777 return modules[name]
--> 778 raise ModuleAttributeError("'{}' object has no attribute '{}'".format(
779 type(self).name, name))
780

ModuleAttributeError: 'MLP' object has no attribute 'DL'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions