PVNet 3.0.49__tar.gz → 3.0.51__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pvnet-3.0.49 → pvnet-3.0.51}/PKG-INFO +1 -1
- {pvnet-3.0.49 → pvnet-3.0.51}/PVNet.egg-info/PKG-INFO +1 -1
- pvnet-3.0.51/pvnet/__init__.py +2 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/base_model.py +28 -16
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/multimodal.py +13 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/utils.py +2 -1
- pvnet-3.0.49/pvnet/__init__.py +0 -2
- {pvnet-3.0.49 → pvnet-3.0.51}/LICENSE +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/MANIFEST.in +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/PVNet.egg-info/SOURCES.txt +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/PVNet.egg-info/dependency_links.txt +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/PVNet.egg-info/requires.txt +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/PVNet.egg-info/top_level.txt +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/README.md +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/callbacks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/base.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/datamodule.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/pv_site_datamodule.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/utils.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/data/wind_datamodule.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/load_model.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/baseline/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/baseline/last_value.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/baseline/single_value.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/ensemble.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/basic_blocks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/encoders/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/encoders/basic_blocks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/encoders/encoders2d.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/encoders/encoders3d.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/encoders/encodersRNN.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/linear_networks/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/linear_networks/basic_blocks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/linear_networks/networks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/multimodal_base.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/site_encoders/__init__.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/site_encoders/basic_blocks.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/site_encoders/encoders.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/models/multimodal/unimodal_teacher.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/optimizers.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/training.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pvnet/utils.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/pyproject.toml +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/setup.cfg +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/tests/test_end2end.py +0 -0
- {pvnet-3.0.49 → pvnet-3.0.51}/tests/test_utils.py +0 -0
|
@@ -13,11 +13,10 @@ import torch
|
|
|
13
13
|
import torch.nn.functional as F
|
|
14
14
|
import wandb
|
|
15
15
|
import yaml
|
|
16
|
-
from huggingface_hub import ModelCard, ModelCardData
|
|
16
|
+
from huggingface_hub import ModelCard, ModelCardData
|
|
17
17
|
from huggingface_hub.constants import CONFIG_NAME, PYTORCH_WEIGHTS_NAME
|
|
18
18
|
from huggingface_hub.file_download import hf_hub_download
|
|
19
19
|
from huggingface_hub.hf_api import HfApi
|
|
20
|
-
from huggingface_hub.utils._deprecation import _deprecate_positional_args
|
|
21
20
|
from ocf_datapipes.batch import BatchKey
|
|
22
21
|
from ocf_ml_metrics.evaluation.evaluation import evaluation
|
|
23
22
|
|
|
@@ -141,33 +140,34 @@ def minimize_data_config(input_path, output_path, model):
|
|
|
141
140
|
yaml.dump(config, outfile, default_flow_style=False)
|
|
142
141
|
|
|
143
142
|
|
|
144
|
-
class PVNetModelHubMixin
|
|
143
|
+
class PVNetModelHubMixin:
|
|
145
144
|
"""
|
|
146
145
|
Implementation of [`PyTorchModelHubMixin`] to provide model Hub upload/download capabilities.
|
|
147
146
|
"""
|
|
148
147
|
|
|
149
148
|
@classmethod
|
|
150
|
-
|
|
151
|
-
def _from_pretrained(
|
|
149
|
+
def from_pretrained(
|
|
152
150
|
cls,
|
|
153
151
|
*,
|
|
154
152
|
model_id: str,
|
|
155
153
|
revision: str,
|
|
156
|
-
cache_dir: str,
|
|
157
|
-
force_download: bool,
|
|
158
|
-
proxies: Optional[Dict],
|
|
159
|
-
resume_download: bool,
|
|
160
|
-
local_files_only: bool,
|
|
161
|
-
token: Union[str, bool, None],
|
|
154
|
+
cache_dir: Optional[Union[str, Path]] = None,
|
|
155
|
+
force_download: bool = False,
|
|
156
|
+
proxies: Optional[Dict] = None,
|
|
157
|
+
resume_download: Optional[bool] = None,
|
|
158
|
+
local_files_only: bool = False,
|
|
159
|
+
token: Union[str, bool, None] = None,
|
|
162
160
|
map_location: str = "cpu",
|
|
163
161
|
strict: bool = False,
|
|
164
|
-
**model_kwargs,
|
|
165
162
|
):
|
|
166
163
|
"""Load Pytorch pretrained weights and return the loaded model."""
|
|
164
|
+
|
|
167
165
|
if os.path.isdir(model_id):
|
|
168
166
|
print("Loading weights from local directory")
|
|
169
167
|
model_file = os.path.join(model_id, PYTORCH_WEIGHTS_NAME)
|
|
168
|
+
config_file = os.path.join(model_id, CONFIG_NAME)
|
|
170
169
|
else:
|
|
170
|
+
# load model file
|
|
171
171
|
model_file = hf_hub_download(
|
|
172
172
|
repo_id=model_id,
|
|
173
173
|
filename=PYTORCH_WEIGHTS_NAME,
|
|
@@ -180,11 +180,23 @@ class PVNetModelHubMixin(PyTorchModelHubMixin):
|
|
|
180
180
|
local_files_only=local_files_only,
|
|
181
181
|
)
|
|
182
182
|
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
# load config file
|
|
184
|
+
config_file = hf_hub_download(
|
|
185
|
+
repo_id=model_id,
|
|
186
|
+
filename=CONFIG_NAME,
|
|
187
|
+
revision=revision,
|
|
188
|
+
cache_dir=cache_dir,
|
|
189
|
+
force_download=force_download,
|
|
190
|
+
proxies=proxies,
|
|
191
|
+
resume_download=resume_download,
|
|
192
|
+
token=token,
|
|
193
|
+
local_files_only=local_files_only,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
with open(config_file, "r", encoding="utf-8") as f:
|
|
197
|
+
config = json.load(f)
|
|
185
198
|
|
|
186
|
-
|
|
187
|
-
model = hydra.utils.instantiate(model_kwargs)
|
|
199
|
+
model = hydra.utils.instantiate(config)
|
|
188
200
|
|
|
189
201
|
state_dict = torch.load(model_file, map_location=torch.device(map_location))
|
|
190
202
|
model.load_state_dict(state_dict, strict=strict) # type: ignore
|
|
@@ -48,6 +48,7 @@ class Model(MultimodalBaseModel):
|
|
|
48
48
|
add_image_embedding_channel: bool = False,
|
|
49
49
|
include_gsp_yield_history: bool = True,
|
|
50
50
|
include_sun: bool = True,
|
|
51
|
+
include_time: bool = False,
|
|
51
52
|
embedding_dim: Optional[int] = 16,
|
|
52
53
|
forecast_minutes: int = 30,
|
|
53
54
|
history_minutes: int = 60,
|
|
@@ -97,6 +98,7 @@ class Model(MultimodalBaseModel):
|
|
|
97
98
|
embedding of the GSP ID.
|
|
98
99
|
include_gsp_yield_history: Include GSP yield data.
|
|
99
100
|
include_sun: Include sun azimuth and altitude data.
|
|
101
|
+
include_time: Include sine and cosine of dates and times.
|
|
100
102
|
embedding_dim: Number of embedding dimensions to use for GSP ID. Not included if set to
|
|
101
103
|
`None`.
|
|
102
104
|
forecast_minutes: The amount of minutes that should be forecasted.
|
|
@@ -141,6 +143,7 @@ class Model(MultimodalBaseModel):
|
|
|
141
143
|
self.include_nwp = nwp_encoders_dict is not None and len(nwp_encoders_dict) != 0
|
|
142
144
|
self.include_pv = pv_encoder is not None
|
|
143
145
|
self.include_sun = include_sun
|
|
146
|
+
self.include_time = include_time
|
|
144
147
|
self.include_wind = wind_encoder is not None
|
|
145
148
|
self.include_sensor = sensor_encoder is not None
|
|
146
149
|
self.embedding_dim = embedding_dim
|
|
@@ -283,6 +286,16 @@ class Model(MultimodalBaseModel):
|
|
|
283
286
|
# Update num features
|
|
284
287
|
fusion_input_features += 16
|
|
285
288
|
|
|
289
|
+
if self.include_time:
|
|
290
|
+
self.time_fc1 = nn.Linear(
|
|
291
|
+
in_features=4
|
|
292
|
+
* (self.forecast_len + self.forecast_len_ignore + self.history_len + 1),
|
|
293
|
+
out_features=32,
|
|
294
|
+
)
|
|
295
|
+
|
|
296
|
+
# Update num features
|
|
297
|
+
fusion_input_features += 32
|
|
298
|
+
|
|
286
299
|
if include_gsp_yield_history:
|
|
287
300
|
# Update num features
|
|
288
301
|
fusion_input_features += self.history_len
|
|
@@ -149,7 +149,8 @@ class WeightedLosses:
|
|
|
149
149
|
self.decay_rate = math.log(2)
|
|
150
150
|
|
|
151
151
|
# make weights from decay rate
|
|
152
|
-
weights =
|
|
152
|
+
weights = np.exp(-self.decay_rate * np.arange(self.forecast_length))
|
|
153
|
+
weights = torch.tensor(weights)
|
|
153
154
|
|
|
154
155
|
# normalized the weights, so there mean is 1.
|
|
155
156
|
# To calculate the loss, we times the weights by the differences between truth
|
pvnet-3.0.49/pvnet/__init__.py
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|