Question about input X's dimension #584
-
I have seen many posts that tutorial about training on 2dimensional's X or 1dimensional's X. And I am going to make a symbolic regression model, which input X is 3-dimenstion and input y is 2-dimension. Could |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You can do it with a custom loss function in the To use const nx = 32
const ny = 20 # For example
function default_objective(tree, dataset::Dataset{T,L}, options)::L where {T,L}
X = dataset.X
(prediction, completion) = eval_tree_array(tree, X, options)
if !completion
return L(Inf)
end
# Here, X is a 2D array of shape [nx * ny, num_features]
# y is a 1D array of shape [nx * ny]
prediction_reshaped = reshape(prediction, (nx, ny))
y_reshaped = reshape(dataset.y, (nx, ny))
# Some computation on the 2D predictions
return L(loss)
end |
Beta Was this translation helpful? Give feedback.
You can do it with a custom loss function in the
loss_function
parameter: https://astroautomata.com/SymbolicRegression.jl/dev/api/ or https://astroautomata.com/PySR/examples/#9-custom-objectives. The idea is to flatten X into a 2D array, and then reshape it to 3D within the loss function.To use
eval_tree_array
you have to pass a 2D array. Imagine batching a computation over all pixels.