Skip to content

ID-154: Loss type selection#70

Merged
AntoxaBarin merged 6 commits intomainfrom
task148_LossTypeSelection
Dec 14, 2023
Merged

ID-154: Loss type selection#70
AntoxaBarin merged 6 commits intomainfrom
task148_LossTypeSelection

Conversation

@AntoxaBarin
Copy link
Contributor

ID-154

Просто добавил селектор в параметры слоя Loss. Для этого пришлось сделать слою Loss отдельный класс (при создании слоя Loss в параметрах теперь не special, а loss), чтоб корректно отображались параметры именно для этого слоя.
Возможно, могли пострадать какие-то функции из-за перехода от special к loss. Если да, то сообщите.

Copy link
Contributor

@Artem-Goldenberg Artem-Goldenberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Написал какие то вопросы, но они не очень важные, так что если все работает то можешь так заливать, или можешь что то подправить но если времени нет то пофиг

loss_type_selector.addEventListener("change", () => {
setModelView("irrelevant")
const parameters = getParametersFromNode(last_selected_node_id)
console.log("last id: " + last_selected_layer_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь принт нужен?

setModelView("irrelevant")
const parameters = getParametersFromNode(last_selected_node_id)
console.log("last id: " + last_selected_layer_id)
const new_value = document.getElementById("loss-type-parameter").value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Здесь можно сразу loss_type_selector.value

Comment on lines +512 to +516
if (new_value == "MSELoss") {
parameters[i][1] = "MSELoss"
} else {
parameters[i][1] = "CrossEntropyLoss"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А нельзя тут сразу присвоить new_value без if?

try {
let ObjData = {
type: "Data",
parameters: "inputs=0;outputs=1;width=2",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

О хорошо, меньше мусорка

Comment on lines 1169 to +1172
case "special":
if (layer.name == "Loss") {
return document.querySelector("#loss-inputs-sortable-list")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А здесь layer.class нельзя сделать loss?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я изначально так и сделал, но потом вернул обратно. Если бы я так и оставил класс loss, то надо было еще в нескольких методах дописывать условия всякие. Если раньше метод проверял, что класс слоя special (data, output, target, loss), то теперь ему бы пришлось проверять еще и класс loss.

document.querySelector("#linear-layer-parameters").style.display = "block"
function setupLayerParameters(layer, layer_id) {
let layer_parameters = getParametersFromNode(layer_id)
console.log(layer_parameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Наверно здесь можно убрать

Comment on lines +1255 to +1264
for (i in layer_parameters) {
if (layer_parameters[i][0] == "bias") {
document.querySelector("#bias-parameter").value = layer_parameters[i][1] == "1"
}
if (layer_parameters[i][0] == "inFeatures") {
document.querySelector("#linear-inFeatures-parameter").value = layer_parameters[i][1]
}
if (layer_parameters[i][0] == "outFeatures") {
document.querySelector("#linear-outFeatures-parameter").value = layer_parameters[i][1]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ну здесь наверное везде тоже можно switch сделать

@AntoxaBarin AntoxaBarin merged commit 18f4679 into main Dec 14, 2023
@AntoxaBarin AntoxaBarin deleted the task148_LossTypeSelection branch December 14, 2023 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants