-
Notifications
You must be signed in to change notification settings - Fork 2
[Stage1] No behind_projector but use so ERROR #10
Description
AttributeError: 'VolCanoMistralForCausalLM' object has no attribute 'behind_projector'
In the project,model/language_model/volcano_mistral.py,you can see that:
# from ..vision_generator.builder import build_vision_generator
from ..front_projector.builder import build_front_projector
# from ..behind_projector.builder import build_behind_projector
from .volcano_base import VolCanoMetaForCausalLM
The content related to behind_projector has been commented out.However, it is used again later in the code.
if visual_labels is not None and text_loss is not None:
if visual_label_masks.sum() == 0:
# # no target images
# if text_loss is not None:
# regression_loss = torch.zeros_like(text_loss)
# else:
# regression_loss = None
last_hidden_state = hidden_states
target_img_hidden_states = torch.masked_select(last_hidden_state[..., :-1, :], (visual_label_masks[:, 1:]>0).unsqueeze(-1)).reshape(-1, hidden_states.shape[-1])
predict_image_feat = self.behind_projector(target_img_hidden_states)
target_visual_labels = torch.masked_select(visual_labels, (visual_label_masks>0).unsqueeze(-1)).reshape(-1, visual_labels.shape[-1])
regression_loss = F.mse_loss(predict_image_feat, target_visual_labels, reduction='none').sum()
loss = self.regression_weight*regression_loss + (2 - self.regression_weight) * text_loss
else:
last_hidden_state = hidden_states
target_img_hidden_states = torch.masked_select(last_hidden_state[..., :-1, :], (visual_label_masks[:, 1:]>0).unsqueeze(-1)).reshape(-1, hidden_states.shape[-1])
predict_image_feat = self.behind_projector(target_img_hidden_states)
target_visual_labels = torch.masked_select(visual_labels, (visual_label_masks>0).unsqueeze(-1)).reshape(-1, visual_labels.shape[-1])
regression_loss = F.mse_loss(predict_image_feat, target_visual_labels)
Thank you for your help!