semantic_args['n_hidden'] = args['semantic_tensor_n_hidden'] _semantic_model = semantic_class(**semantic_args) combined_args = { 'w_trainer':_syntactic_model, 'v_trainer':_semantic_model, 'vocab_size':vocab_size, 'indices_in_intersection':list(indices_in_intersection), 'dimensions':args['dimensions'], 'w_loss_multiplier':args['w_loss_multiplier'], 'other_params':args, 'mode':args['mode'] } if args['simple_joint']: model = Joint(**combined_args) else: combined_args['rho'] = args['rho'] model = ADMM(**combined_args) def save_model(filename=None): if filename is None: filename = 'model-%d.pkl.gz' % model.k fname = os.path.join(args['base_dir'], filename) sys.stdout.write('dumping model to %s' % fname) sys.stdout.flush() with gzip.open(fname, 'wb') as f: cPickle.dump(model, f) sys.stdout.write('\r') sys.stdout.flush()
_semantic_model = SimilarityNN(**semantic_args) combined_args = { 'w_trainer':_syntactic_model, 'v_trainer':_semantic_model, 'vocab_size':args['vocab_size'], 'indices_in_intersection':list(indices_in_intersection), 'dimensions':args['dimensions'], 'w_loss_multiplier':args['w_loss_multiplier'], 'other_params':args, 'mode':args['mode'] } if args['simple_joint']: model = Joint(**combined_args) else: combined_args['rho'] = args['rho'] model = ADMM(**combined_args) def save_model(): fname = os.path.join(args['base_dir'], 'model-%d.pkl.gz' % model.k) sys.stdout.write('dumping model to %s' % fname) sys.stdout.flush() with gzip.open(fname, 'wb') as f: cPickle.dump(model, f) sys.stdout.write('\r') sys.stdout.flush() # save the initial state if not model_loaded:
_semantic_model = SimilarityNN(**semantic_args) combined_args = { 'w_trainer': _syntactic_model, 'v_trainer': _semantic_model, 'vocab_size': args['vocab_size'], 'indices_in_intersection': list(indices_in_intersection), 'dimensions': args['dimensions'], 'w_loss_multiplier': args['w_loss_multiplier'], 'other_params': args, 'mode': args['mode'] } if args['simple_joint']: model = Joint(**combined_args) else: combined_args['rho'] = args['rho'] model = ADMM(**combined_args) def save_model(): fname = os.path.join(args['base_dir'], 'model-%d.pkl.gz' % model.k) sys.stdout.write('dumping model to %s' % fname) sys.stdout.flush() with gzip.open(fname, 'wb') as f: cPickle.dump(model, f) sys.stdout.write('\r') sys.stdout.flush() # save the initial state if not model_loaded:
semantic_args['n_hidden'] = args['semantic_tensor_n_hidden'] _semantic_model = semantic_class(**semantic_args) combined_args = { 'w_trainer': _syntactic_model, 'v_trainer': _semantic_model, 'vocab_size': vocab_size, 'indices_in_intersection': list(indices_in_intersection), 'dimensions': args['dimensions'], 'w_loss_multiplier': args['w_loss_multiplier'], 'other_params': args, 'mode': args['mode'] } if args['simple_joint']: model = Joint(**combined_args) else: combined_args['rho'] = args['rho'] model = ADMM(**combined_args) def save_model(filename=None): if filename is None: filename = 'model-%d.pkl.gz' % model.k fname = os.path.join(args['base_dir'], filename) sys.stdout.write('dumping model to %s' % fname) sys.stdout.flush() with gzip.open(fname, 'wb') as f: cPickle.dump(model, f) sys.stdout.write('\r') sys.stdout.flush()