Fix AllVectors bug.

This commit is contained in:
Haifeng Luo 2022-04-12 23:50:20 +08:00
parent 17a8234773
commit 19e69f5562
3 changed files with 8 additions and 8 deletions

View File

@ -28,11 +28,11 @@ func testTsne() {
func (vectorset *Vectorset) DoTsne(dimension int) {
floatArray := []float64{}
for _, vector := range vectorset.Vectors {
for _, vector := range vectorset.AllVectors {
floatArray = append(floatArray, vector.Data...)
}
X := mat.NewDense(len(vectorset.Vectors), vectorset.Dimension, floatArray)
X := mat.NewDense(len(vectorset.AllVectors), vectorset.Dimension, floatArray)
t := tsne.NewTSNE(dimension, 300, 100, 300, true)
@ -42,14 +42,14 @@ func (vectorset *Vectorset) DoTsne(dimension int) {
})
rowCount, columnCount := Y.Dims()
if rowCount != len(vectorset.Vectors) {
panic("rowCount != len(vectorset.Vectors)")
if rowCount != len(vectorset.AllVectors) {
panic("rowCount != len(vectorset.AllVectors)")
}
if columnCount != dimension {
panic("columnCount != dimension")
}
for i, vector := range vectorset.Vectors {
for i, vector := range vectorset.AllVectors {
arr := []float64{}
for j := 0; j < dimension; j++ {
arr = append(arr, Y.At(i, j))

View File

@ -10,8 +10,8 @@ func TestDoVectorsetTsne(t *testing.T) {
dimension := 50
vectorset := getVectorset("admin", "百度百科")
//vectorset := getVectorset("admin", "wordVector_utf-8")
//vectorset := getVectorset("admin", "百度百科")
vectorset := getVectorset("admin", "wordVector_utf-8")
vectorset.LoadVectors("../../tmpFiles/")
vectorset.DoTsne(dimension)

View File

@ -315,7 +315,7 @@ class WordsetGraph extends React.Component {
</span>
</Col>
<Col style={{marginTop: '5px', textAlign: 'center'}} span={12}>
<InputNumber style={{width: "100%"}} min={1} max={20} step={1} value={this.state.distanceLimit} onChange={value => {
<InputNumber style={{width: "100%"}} min={1} max={100} step={1} value={this.state.distanceLimit} onChange={value => {
this.setState({
distanceLimit: value,
});