rng(seed) strange behaviour at first call of script after matlab startup

3 ビュー (過去 30 日間)
Fabian Hirmann
Fabian Hirmann 2018 年 6 月 1 日
編集済み: Walter Roberson 2018 年 6 月 3 日
Hi,
I use matlab for machine learning with neural networks and have a strange behaviour with setting the seed fixed at the beginning of my script. This is to have reproducible results at every call of the script.
At first call of the script after start of matlab the results are different than the following. After the first call the following calls produce the same results as expected. All first calls after startup do also produce the same results than the other first calls.
I set a fixed seed at startup just with:
rng(0)
% rest of script
I hope somebody can help me.
Edit:
As asked in the comments I provide a minimum working example. script.m is the script and data.csv contains the data. In the script first the data is loaded, then the seed is set, then the data is adapted to the neural network (first column is output class and all other columns are input features) and then the network is trained and tested. The differences of the first and following calls can be examined by e.g. the variable percentErrors. On my system (Windows 10 Home (Version: 1803) 64-bit, Matlab R2016a) the first call of the script leads to a value of 0.96. The second and the following calls lead to a value of 0.98.
  1 件のコメント
Stephen23
Stephen23 2018 年 6 月 1 日
@Fabian Hirmann: this sounds like an interesting problem. Please:
  • show us your OS and MATLAB version.
  • upload an MWE that demonstrates this problem (click the paperclip to upload files).

サインインしてコメントする。

回答 (1 件)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy 2018 年 6 月 1 日
編集済み: Walter Roberson 2018 年 6 月 3 日
  1 件のコメント
Fabian Hirmann
Fabian Hirmann 2018 年 6 月 1 日
Thanks for your response.
First of all I had to replace setDefaultStream(...) with setGlobalStream(...) as stated in [1].
Secondly there were also then the same strange results as described in my question.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品


リリース

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by