コード例 #1
0
def synthesize_tensor(dims, datatype, using_ratio, noise):
    real_dim = 100
    means = [
        np.ones((real_dim, )) * 5,
        np.ones((real_dim, )) * 10,
        np.ones((real_dim, )) * 2
    ]
    covariances = [
        np.eye(real_dim) * 2,
        np.eye(real_dim) * 3,
        np.eye(real_dim) * 2
    ]

    if datatype == "binary":
        tensor = binary_tensor()
    elif datatype == "real":
        tensor = RV_tensor()
    elif datatype == "count":
        tensor = count_tensor()
    """
    """
    tensor.synthesize_data(dims, means, covariances, real_dim, \
                           train=0.8, sparsity=1, noise=noise, noise_ratio=using_ratio)
    # tensor.reduce_train_size(0.1)
    return tensor
コード例 #2
0
ファイル: synthetic_test.py プロジェクト: dnguyen1196/SSVI-TF
def synthesize_matrix(dims, datatype, noise_ratio, noise_amount):
    real_dim = 100
    means = [np.ones((real_dim,)) * 5, np.ones((real_dim,)) * 2]
    covariances = [np.eye(real_dim) * 2, np.eye(real_dim) * 3]

    if datatype == "binary":
        tensor = binary_tensor()
    elif datatype == "real":
        tensor = RV_tensor()
    else:
        tensor = count_tensor()

    tensor.synthesize_data(dims, means, covariances, real_dim, \
                           train=0.8, sparsity=1, noise=noise_amount, noise_ratio=noise_ratio)
    return tensor
コード例 #3
0
ファイル: main.py プロジェクト: dnguyen1196/SSVI-TF
def test_learning_curve(datatype, model):
    assert (datatype in ["real", "binary", "count"])
    assert (model in ["deterministic", "simple", "robust"])
    mean_update = "S"
    cov_update = "N"
    tensor = None
    D = 20
    if datatype == "real":
        tensor = RV_tensor()
        mean0 = np.ones((D, )) * 5
        cov0 = np.eye(D)

    elif datatype == "binary":
        tensor = binary_tensor()
        mean0 = np.zeros((D, ))
        cov0 = np.eye(D)

    elif datatype == "count":
        tensor = count_tensor()

    factorizer = None
    fact_D = 20

    if model == "deterministic":
        factorizer = SSVI_TF_d(real_tensor, rank=fact_D, \
                               mean_update=mean_update, cov_update=cov_update, \
                               k1=64, k2=64, \
                               mean0=mean0, cov0=cov0)
    elif model == "simple":
        factorizer = SSVI_TF_simple(data, rank=D, \
                                    mean_update=mean_update, cov_update=cov_update, \
                                    k1=64, k2=64, \
                                    mean0=mean0, cov0=cov0)

    elif model == "robust":
        factorizer = SSVI_TF_robust(data, rank=D, \
                                    mean_update=mean_update, cov_update=cov_update, \
                                    mean0=mean0, cov0=cov0, k1=128, k2=64, \
                                    eta=1, cov_eta=0.1)

    do_learning_curve(factorizer, tensor)
コード例 #4
0
ファイル: factorize.py プロジェクト: dnguyen1196/SSVI-TF
                    default=500)
parser.add_argument("-m",
                    "--model",
                    type=str,
                    help="model being used",
                    choices=["deterministic", "simple", "robust"])

args = parser.parse_args()

filename = args.filename
datatype = args.datatype
model = args.model

tensor = None
if datatype == "count":
    tensor = count_tensor()
    tensor.read_from_file(filename, 0.7, 0.1, 0.2)
    print("min_count:", tensor.min_count)
    print("max_count:", tensor.max_count)

D = 50

default_params = {
    "mean_update": "S",
    "cov_update": "N",
    "rank": D,
    "k1": 64,
    "k2": 64
}