non-deterministic

Seeded Python RNG showing non-deterministic behavior with sets

可紊 提交于 2021-01-27 05:43:50
问题 I'm seeing non-deterministic behavior when trying to select a pseudo-random element from sets, even though the RNG is seeded (example code shown below). Why is this happening, and should I expect other Python data types to show similar behavior? Notes: I've only tested this on Python 2.7, but it's been reproducible on two different Windows computers. Similar Issue: The issue at Python random seed not working with Genetic Programming example code may be similar. Based on my testing, my

Why is dictionary ordering non-deterministic?

别来无恙 提交于 2020-01-14 14:33:09
问题 I recently switched from Python 2.7 to Python 3.3, and it seems that while in Python 2 the ordering of dictionary keys was arbitrary but consistent, in Python 3 the ordering of the keys of a dictionary obtained with e.g. vars() appears non-deterministic. If I run: class Test(object): pass parameters = vars(Test) print(list(parameters.keys())) in both Python 2.7 and Python 3.3, then: Python 2.7 consistently gives me ['__dict__', '__module__', '__weakref__', '__doc__'] With Python 3.3, I can

Indeterministic sets in Python 2 and 3

蹲街弑〆低调 提交于 2019-12-31 07:24:06
问题 Python 2 Sets are collections of unordered values. If I construct a set via a set literal, e.g. s = {'a', 'b', 'c'} and then print it, I get the elements in some scrambled order. However, it seems that in Python 2.7, the above example always results in the same ordering: print(s) # set(['a', 'c', 'b']) in Python 2.7 How does Python 2.7 decide on this ordering? Even the hashes of 'a' , 'b' and 'c' are not in the order produced. Python 3 In Python 3.x (including 3.6 where dict keys are ordered)

Combine ST and List monads in Haskell

人走茶凉 提交于 2019-12-23 15:08:33
问题 Using the StateT monad transformer, I can create the type StateT s [] a , which is isomorphic to s -> [(a, s)] . Now I would prefer to use the STT monad transformer instead, as I would like to have multiple mutable variables of different types, and would like to be able to instantiate them at will, depending on the results of earlier computations. However, the linked documentation for STT mentions explicitly: This monad transformer should not be used with monads that can contain multiple

Why is the non-deterministic choice function in Curry's std lib not defined straightforwardly but rather with a helper 2-argument function?

情到浓时终转凉″ 提交于 2019-12-21 07:26:07
问题 Consider a function choose in Curry programming language with the specification that " (choose xs) non-deterministically chooses one element from the list xs ". I'd implement it straighforwardly through two alternative non-deterministic rules: choose :: [a] -> a choose x:_ = x choose _:xs = choose xs But in /usr/lib/curry-0.9.11/Success.curry from Muenster Curry Compiler, it is defined with a helper function: choose (x:xs) = choosep x xs where choosep x [] = x choosep x (_:_) = x choosep _ (x

Can precision of floating point numbers in Javascript be a source of non determinism?

随声附和 提交于 2019-12-18 14:54:26
问题 Can the same mathematical operation return different results in different architectures or browsers ? 回答1: Although the ECMAScript language specification 5.1 edition states that numbers are primitive values corresponding to IEEE 754 floats, which implies calculations should be consistent: http://www.ecma-international.org/publications/files/ecma-st/ECMA-262.pdf 4.3.19 Number value primitive value corresponding to a double-precision 64-bit binary format IEEE 754 value NOTE A Number value is a

Creating Nondeterministic functions in SQL Server using RAND()

左心房为你撑大大i 提交于 2019-12-17 20:18:27
问题 After a bit of searching and reading the documentation, it's clear that you can write user defined functions in SQL Server that are marked as either deterministic or nondeterministic depending on which built-infunctions are used within the body. RAND() is listed under the nondeterministic functions (see msdn article). So why can't I use it in a function? 回答1: Because it has side effects. Constructs with side effects are not allowed in a function. The side effect that it has is to change some

Track non-deterministic MySQL errors in Perl

若如初见. 提交于 2019-12-13 13:31:04
问题 I have a single-thread Perl script running on a hosted shared server that mainly executes the following code: my $O_dbh = DBI->connect("dbi:mysql:dbname=dbname", "abc", "xxx", {RaiseError => 1}); $O_dbh->begin_work(); my $O_sth1 = $O_dbh->prepare('SELECT COUNT(*) FROM mytable WHERE any = 5'); $O_sth1->execute(); my @result1 = $O_sth1->fetchrow_array(); my $oldValue = $result1[0]; $O_sth1->finish(); my $O_sth2 = $O_dbh->prepare('INSERT INTO mytable (any) VALUES (5)'); $O_sth2->execute(); $O

Why does SQL Server say this function is nondeterministic?

孤人 提交于 2019-12-13 02:53:38
问题 Execute this function in T-SQL: CREATE FUNCTION [dbo].[Parse_URI_For_Scheme]( @URI nvarchar(4000)) RETURNS nvarchar(250) WITH SCHEMABINDING AS BEGIN DECLARE @temp_string varchar(4000) DECLARE @return_string nvarchar(250) DECLARE @pos int SET @pos = CHARINDEX('://', @URI); --select @pos IF @pos > 0 BEGIN SET @temp_string = SUBSTRING(@URI, 0, @pos); -- SET @pos = CHARINDEX('/', @temp_string) IF @pos > 0 BEGIN SET @temp_string = LEFT(@temp_string, @pos - 1); SET @pos = CHARINDEX('@', @temp

Non-deterministic Gradient Computation

做~自己de王妃 提交于 2019-12-10 13:47:02
问题 I realized that my models end up being different every time I train them, even though I keep the TensorFlow random seed the same. I verified that: Initialization is deterministic; the weights are identical before the first update. Inputs are deterministic. In fact, various forward computations, including the loss, are identical for the very first batch. The gradients for the first batch are different. Concretely, I'm comparing the outputs of tf.gradients(loss, train_variables) . While loss