Skip to content

Commit ff99e4d

Browse files
authored
fix: fix model input shape bug and costeer_model bug (microsoft#821)
* fix model input shape bug and costeer_model bug * fix a bug
1 parent c5beaee commit ff99e4d

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

rdagent/components/coder/model_coder/evolving_strategy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def implement_one_task(
5252
if isinstance(queried_knowledge, CoSTEERQueriedKnowledgeV2)
5353
else queried_former_failed_knowledge
5454
)
55-
5655
system_prompt = (
5756
Environment(undefined=StrictUndefined)
5857
.from_string(
@@ -61,7 +60,7 @@ def implement_one_task(
6160
.render(
6261
scenario=self.scen.get_scenario_all_desc(filtered_tag=target_task.model_type),
6362
queried_former_failed_knowledge=queried_former_failed_knowledge_to_render,
64-
current_code=target_task.base_code,
63+
current_code=workspace.file_dict.get("model.py"),
6564
)
6665
)
6766

rdagent/components/coder/model_coder/model_execute_template_v1.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ if MODEL_TYPE == "Tabular":
1616
m = model_cls(num_features=input_shape[1])
1717
data = torch.full(input_shape, INPUT_VALUE)
1818
elif MODEL_TYPE == "TimeSeries":
19-
input_shape = (BATCH_SIZE, NUM_FEATURES, NUM_TIMESTEPS)
20-
m = model_cls(num_features=input_shape[1], num_timesteps=input_shape[2])
19+
input_shape = (BATCH_SIZE, NUM_TIMESTEPS, NUM_FEATURES)
20+
m = model_cls(num_features=input_shape[2], num_timesteps=input_shape[1])
2121
data = torch.full(input_shape, INPUT_VALUE)
2222
elif MODEL_TYPE == "Graph":
2323
node_feature = torch.randn(BATCH_SIZE, NUM_FEATURES)

rdagent/scenarios/qlib/experiment/prompts.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ qlib_model_background: |-
156156
3. Architecture: The detailed architecture of the model, such as neural network layers or tree structures.
157157
4. Hyperparameters: The hyperparameters used in the model, such as learning rate, number of epochs, etc.
158158
5. ModelType: The type of the model, "Tabular" for tabular model and "TimeSeries" for time series model.
159-
The model should provide clear and detailed documentation of its architecture and hyperparameters. One model should statically define one output with a fixed architecture and hyperparameters. For example, a model with an two GRU layer and a model with three GRU layer should be considered two different models.
159+
The model should provide clear and detailed documentation of its architecture and hyperparameters. One model should statically define one output with a fixed architecture and hyperparameters.
160160
161161
qlib_model_interface: |-
162162
Your python code should follow the interface to better interact with the user's system.
@@ -176,7 +176,7 @@ qlib_model_interface: |-
176176
model_cls = XXXModel
177177
```
178178
179-
The model has two types, "Tabular" for tabular model and "TimeSeries" for time series model. The input shape to a tabular model is (batch_size, num_features) and the input shape to a time series model is (batch_size, num_features, num_timesteps). The output shape of the model should be (batch_size, 1).
179+
The model has two types, "Tabular" for tabular model and "TimeSeries" for time series model. The input shape to a tabular model is (batch_size, num_features) and the input shape to a time series model is (batch_size, num_timesteps, num_features). The output shape of the model should be (batch_size, 1).
180180
The "batch_size" is a dynamic value which is determined by the input of forward function.
181181
The "num_features" and "num_timesteps" are static which will be provided to the model through init function.
182182
User will initialize the tabular model with the following code:
@@ -189,8 +189,6 @@ qlib_model_interface: |-
189189
```
190190
No other parameters will be passed to the model so give other parameters a default value or just make them static.
191191
192-
When dealing with TimeSeries model, remember to permute the input tensor since the input tensor is in the shape of (batch_size, num_features, num_timesteps) and a normal time series model is expecting the input tensor in the shape of (batch_size, num_timesteps, num_features).
193-
194192
Don't write any try-except block in your python code. The user will catch the exception message and provide the feedback to you. Also, don't write main function in your python code. The user will call the forward method in the model_cls to get the output tensor.
195193
196194
Please notice that your model should only use current features as input. The user will provide the input tensor to the model's forward function.

0 commit comments

Comments
 (0)