說明
Well, 最近正在趕論文,也正在學習如何使用Weka。但是,當我裝好了Weka,興高采烈地想要開始使用時,它卻無情地給我在螢幕上留下了如此的訊息:
等一下,明明我之前在筆電用的好好的啊,為什麼在我的桌機上安裝卻出了這個問題?
一頭霧水的我,只好無奈地摸摸鼻子,上網搜尋看看,是不是有其他和我一樣的受害者。
果不其然,一堆網頁教導我們如何增加Weka的Heap Size。
網頁上已經有提供了二種解決方式:
1. 如上述警告視視窗所教導的,將啟動Weka的指令中,加入「-Xmx128m」(設定為128MB的Heap Size)。
2. 修改「Runweka.ini」中的「maxheap」值。
解決方法之一: 將啟動Weka的指令中,加入「-Xmx128m」(設定為128MB的Heap Size)。
1. 在Weka的安裝目錄中,找到名為「Runweka.bat」的檔案,並用記事本軟體開啟。
可看到如下內容 (請注意到最後一行,就是我們要修改的部份)
1: @echo off
2:
3: REM Batch file for executing the RunWeka launcher class.
4:
5: REM RunWeka.bat <command>
6:
7: REM Run with option "-h" to see available commands
8:
9: REM
10:
11: REM Notes:
12:
13: REM - If you're getting an OutOfMemory Exception, increase the value of
14:
15: REM "maxheap" in the RunWeka.ini file.
16:
17: REM - If you need more jars available in Weka, either include them in your
18:
19: REM %CLASSPATH% environment variable or add them to the "cp" placeholder
20:
21: REM in the RunWeka.ini file.
22:
23: REM
24: REM Author: FracPete (fracpete at waikato dot ac dot nz)
25:
26: REM Version: $Revision: 1.6 $
27:
28: set _cmd=%1
29:
30: set _java=javaw
31:
32: if "%_cmd%"=="" set _cmd=default
33:
34: if "%_cmd%"=="-h" set _java=java
35:
36: %_java% -classpath . RunWeka -i .\RunWeka.ini -w .\weka.jar -c %_cmd% "%2"
2. 在最後一行的後方加入如下指令「-Xmx1024m」,指令中的1024代表我們將設定1024MB為Weka的Heap Size。
1: %_java% -classpath . RunWeka -i .\RunWeka.ini -w .\weka.jar -c %_cmd% "%2" -Xmx1024m
3. 完成。
解決方法之二: 修改「Runweka.ini」中的「maxheap」值。
1. 在Weka的安裝目錄中,找到名為「Runweka.ini」的檔案,並用記事本軟體開啟。
可看到如下內容 (請找到開頭為「maxheap=」的那一行,就是我們要修改的部份)
我們可以看到目前的設定是「maxheap=256m」,也就是說Heap Size是256MB。
1: # Contains the commands for running Weka either with a command prompt
2:
3: # ("cmd_console") or without the command prompt ("cmd_default").
4:
5: # One can also define custom commands, which can be used with the Weka
6:
7: # launcher "RunWeka.class". E.g., to run the launcher with a setup called
8:
9: # "custom1", you only need to specify a key "cmd_custom1" which contains the
10:
11: # command specification.
12:
13: #
14:
15: # Notes:
16:
17: # - This file is not a DOS ini file, but a Java properties file.
18:
19: # - The settings listed here are key-value pairs, separated by a "=". Every
20:
21: # key can only be listed ONCE.
22:
23: #
24:
25: # Author FracPete (fracpete at waikato dot ac dot nz)
26:
27: # Version $Revision: 1.3 $
28:
29: # setups (prefixed with "cmd_")
30:
31: cmd_default=javaw -Dfile.encoding=#fileEncoding# -Xmx#maxheap# -classpath "#wekajar#;#cp#" #mainclass#
32:
33: cmd_console=cmd.exe /K start cmd.exe /K "java -Dfile.encoding=#fileEncoding# -Xmx#maxheap# -classpath \"#wekajar#;#cp#\" #mainclass#"
34:
35: cmd_explorer=javaw -Dfile.encoding=#fileEncoding# -Xmx#maxheap# -classpath "#wekajar#;#cp#" weka.gui.explorer.Explorer
36:
37: cmd_knowledgeFlow=java -Dfile.encoding=#fileEncoding# -Xmx#maxheap# -classpath "#wekajar#;#cp#" weka.gui.beans.KnowledgeFlow
38:
39: # placeholders ("#bla#" in command gets replaced with content of key "bla")
40:
41: # Note: "#wekajar#" gets replaced by the launcher class, since that jar gets
42:
43: # provided as parameter
44:
45: maxheap=256m
2. 修改「maxheap」值。
這個數值,可視自己電腦的記憶體數量為何來設定,不要超過自己的記憶體數量,設定個五成應該就夠用了。
(記憶體1G = 1024m)
maxheap=1024m |
1 則留言:
版主你好
目前我照你的方法可以更改Maxheap
但對於heap size還是無法更改
我目前用的版本是Weka 3.6
不知道有沒有甚麼撇步
張貼留言