0

誰かがこれが何を意味するのか説明してください。

背景: 「ネットワーク」はクラスであり、ニューラル ネットワーク オブジェクトを表します。そのコンストラクターには、次のようないくつかの入力が必要です。ノード、入力、出力、num_functions など。ただし、参照として使用している python 実装では、辞書を使用してこれらのパラメーターをコンストラクターにロードします (これが起こっていると思います)。これがnetwork(**config)でどのように機能するかを説明できる人はいますか? Ps。これをJavaに変換しています。

ネットワーク クラスのコンストラクタは次のようになります。

public network(int _graph_length, int _input_length, int _output_length, int _max_arity, int _function_length){

辞書はこれを行います:

output is a dictionary used to store data.
config is a dictionary uses to load parameters for the NN.

そして、私が理解していないコードは次のとおりです。

//Output data reset:
output.put("skipped", 0);
output.put("estimated", 0);

//if single mutation method:
if (config.get("speed") == "single"){       
    network.mutate = network.one_active_mutation;
    }

    parent = network(**config);
    yield parent;
while true: 
    //code to evolve networks here!
4

1 に答える 1

1

network(**config)はディクショナリをアンパックし、configそのディクショナリ内のキーと値のペアを への引数として使用しますnetwork

たとえば、これらはすべて次のように同じ呼び出しを行いfuncます。

def func(foo, bar):
    print foo, bar

d = {'foo': 'value1', 'bar': 'value2'}

func(**d)
func(**{'bar': 'value2', 'foo': 'value1'})
func(bar='value2', foo='value1')
func('value1', 'value2')
于 2013-08-06T14:12:55.590 に答える