Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed "BatchKey" and fixed dependents #328 #330

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
17 changes: 14 additions & 3 deletions pvnet/models/multimodal/site_encoders/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import einops
import torch
from ocf_datapipes.batch import BatchKey
from torch import nn

from pvnet.models.multimodal.linear_networks.networks import ResFCNet2
Expand Down Expand Up @@ -75,13 +74,25 @@ def __init__(
)

def _calculate_attention(self, x):
gsp_ids = x[BatchKey.gsp_id].squeeze().int()
# added this for loop to correctly acess the enum object
i = 0
for key in x.keys():
if i == 17:
ans = key
i += 1
gsp_ids = x[ans].squeeze().int()
attention = self._attention_network(gsp_ids)
return attention

def _encode_value(self, x):
# Shape: [batch size, sequence length, PV site]
pv_site_seqs = x[BatchKey.pv].float()
# added this for loop to correctly acess the enum object
i = 0
for key in x.keys():
if i == 6:
ans = key
i += 1
pv_site_seqs = x[ans].float()
batch_size = pv_site_seqs.shape[0]

pv_site_seqs = pv_site_seqs.swapaxes(1, 2).flatten(0, 1)
Expand Down