Exemple #1
0
    print(
        'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 /opt/nec/frovedis/ve/bin/frovedis_server")'
    )
    quit()
FrovedisServer.initialize(argvs[1])

mat = np.random.randint(5, size=(6, 50))
mat = np.asmatrix(mat, dtype=np.float64)
cmat = FrovedisCRSMatrix(mat, dtype=np.float64)
lbl = np.array([1, 1, -1, 1, -1, 1], dtype=np.float64)

# fitting input matrix and label on Factorization Machine Classifier object
fmc = FactorizationMachineClassifier(iteration=100,
                                     init_stdev=0.1,
                                     init_learn_rate=0.01,
                                     optimizer="SGD",
                                     dim=(True, True, 8),
                                     reg=(False, False, 0),
                                     batch_size_pernode=5000,
                                     verbose=0).fit(cmat, lbl)

# prediction on created model
print("predicting on factorization machine classifier model: ")
print(fmc.predict(cmat))

# saving the model
fmc.save("./out/FMCModel")

mat2 = np.random.randint(5, size=(8, 50))
mat2 = np.asmatrix(mat2, dtype=np.float64)
cmat2 = FrovedisCRSMatrix(mat2, dtype=np.float64)
lbl2 = np.array([1.2, 0.3, 1.1, 1.9, 1.7, 0.5, 1.2, 1.1], dtype=np.float64)
Exemple #2
0
from frovedis.exrpc.server import FrovedisServer
from frovedis.matrix.crs import FrovedisCRSMatrix
from frovedis.matrix.dvector import FrovedisDoubleDvector
from frovedis.mllib.fm import FactorizationMachineClassifier

#obj: passing negative  vervose value

# initializing the Frovedis server
argvs = sys.argv
argc = len(argvs)
if (argc < 2):
    print ('Please give frovedis_server calling command as the first argument \n')
    quit()
FrovedisServer.initialize(argvs[1])

mat = FrovedisCRSMatrix(dtype=np.float64).load("./input/classification.txt")
lbl = FrovedisDoubleDvector([1,1,1,-1,-1,1,-1,1,-1,1])
# fitting input matrix and label on Factorization Machine Classifier object

fm_obj = FactorizationMachineClassifier(iteration = 100, init_stdev = 0.1,
               init_learn_rate = 0.1, optimizer="LBFGS", dim = (True, True, 8),
               reg = (0, 0, 0), batch_size_pernode = 1, verbose = -1)

try:
  model = fm_obj.fit(mat, lbl)
  print("Failed") 
except:
  print("Passed")

FrovedisServer.shut_down()