forked from MockaWolke/iannwtf1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataset.py
39 lines (26 loc) · 839 Bytes
/
dataset.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
""""
Dataset
Provides data with labels: and, or, nand, nor, xor
"""
import numpy as np
# all resonable logic gate inputs
inputs = np.array([(1,0),(1,1),(0,0),(0,1)])
# and labels
and_lables = np.array([i[0] & i[1] for i in inputs])
# or labels
or_lables = np.array([i[0] | i[1] for i in inputs])
def random_data(kind='xor'):
""" random_data returns labeled data dependent on input parameter
## Params
- kind = "and" or "or" or "nand" or "nor" or "xor" (standard = "xor")
"""
if kind == "and":
return inputs, and_lables
if kind == "or":
return inputs, or_lables
if kind == "nand":
return inputs,1- and_lables
if kind == "nor":
return inputs, 1- or_lables
if kind == "xor":
return inputs, 1- (and_lables & or_lables)