Closed luxiant closed 1 year ago
@luxiant,
can you try to print out tensors to check? Something like this:
fmt.Printf("torchResult: %i\n", torchResult)
sm := torchResult.MustSoftmax(-1, gotch.Double, true)
fmt.Printf("softmax tensor: %i\n", sm)
categoryProb := sm.Float64Values()
fmt.Printf("categoryProb: %v\n", categoryProb) // if error occurs at above line, won't see this log.
There are some memory leakages in your code, but will discuss later.
Please report the logs. Thanks.
Uhhhhhh.....I feel bad for bothering you with this. Eventually, I finally found the cause after one day and a half of troubleshooting and that was because of my silly mistake.
The problem was not there that I pasted, but was in the process for loading my pretrained bert model. The correct way to load bertconfig file that you've suggested in the example was
bertConfig, _ := bert.ConfigFromFile("model/bert_config.json") // load bert config file
var dummyLabelMap map[int64]string = make(map[int64]string)
dummyLabelMap[0] = "long"
dummyLabelMap[1] = "neutral"
dummyLabelMap[2] = "short"
bertConfig.Id2Label = dummyLabelMap
bertConfig.OutputAttentions = true
bertConfig.OutputHiddenStates = true
But I mistakenly erased some part and tried to run this code.
bertConfig, _ := bert.ConfigFromFile("model/bert_config.json") // load bert config file
var dummyLabelMap map[int64]string = make(map[int64]string)
bertConfig.OutputAttentions = true
bertConfig.OutputHiddenStates = true
I corrected this and the problem solved.
I'm working with my project and hit by this error during debugging.
''' root@codespaces-e73b16:/workspaces/KoBERT# go run main.go 2023/03/05 07:00:02 INFO: CachedDir="/root/.cache/transformer" Successfully loaded model 0% | | (0/100, 0 it/hr) [0s:0s]2023/03/05 07:00:06 Unsupported Go type: []float64 exit status 1 '''
I searched all of the variables throughout my code with []float64 type, but in this part of my code the line inside of the function 'bertSentimentProcess'
is the only one in which the variable takes []float64 type. I'm trying to figure out why the bug happens but still can't get it. []float64 is a supported Go type, so I thought this error should not happen. I first assumed that this is a language error, but even after reinstalling Go 1.19 I'm still getting a same error.