I'm searching for an algorithm that generates all permutations of fixed-length partitions of an integer. Order does not matter.
For example, for n=4 and length L=3:
[(0, 2, 2), (2, 0, 2), (2, 2, 0),
(2, 1, 1), (1, 2, 1), (1, 1, 2),
(0, 1, 3), (0, 3, 1), (3, 0, 1), (3, 1, 0), (1, 3, 0), (1, 0, 3),
(0, 0, 4), (4, 0, 0), (0, 4, 0)]
Run Code Online (Sandbox Code Playgroud)
I bumbled about with integer partitions + permutations for …
我有一个文件列表,我想把它分成 3 部分:训练、验证和测试。我试过这段代码,我不知道它是否正确。
files = glob.glob("/dataset/%s/*" % emotion)
training = files[:int(len(files)*0.8)] #get first 80% of file list
validation = files[-int(len(files)*0.1):] #get middle 10% of file list
testing = files[-int(len(files)*0.1):] #get last 10% of file list
Run Code Online (Sandbox Code Playgroud)
我不确定测试列表是重复的还是文件列表的最后 10% 是正确的。