name=NAME)) model.add(Flatten(name='FLATTEN')) model.add(Dense(units=10, name='FINAL_DENSE')) model.compile(loss=lib_tflow.loss, optimizer=lib_tflow.opt, metrics=['accuracy']) self.model = model Model = Max() if args.nodes > 1: distribute(strategy, Model, args.nodes) else: Model.create() dataset = give(DIM, args.numf, args.channels) dataset = dataset.batch(args.batch) if args.nodes > 1: dataset = strategy.experimental_distribute_dataset(dataset) steps = ds_size // args.batch // args.nodes the_typs = ['MaxPool'] time = lib_tflow.profile(the_typs, None, Model.model, dataset, steps, args.epochs) import numpy as np
parser.add_argument('-epochs', type=int, required=True) args = parser.parse_args() print('model:', args.model, 'dataset size:', args.ds, 'numf:', args.numf, 'channels:', args.ch, 'out:', args.out) Model = getattr(tflow_models, args.model)() if args.nodes > 1: model = tflow_lib.distribute(strategy, Model, args.nodes) else: model = Model.create() ds_size = args.ds dataset = tf_data.give(2, args.numf, args.ch, out_size=args.out, ds_size=ds_size) dataset = dataset.batch(args.batch) if args.nodes > 1: dataset = strategy.experimental_distribute_dataset(dataset) steps = max(ds_size / args.batch / args.nodes, 1) the_time = tflow_lib.profile(model, dataset, steps, args.epochs) import socket host = socket.gethostname()
model = Sequential() model.add(Flatten(name='FLATTEN')) model.add(Dense(units=args.units, name='FINAL_DENSE')) model.compile(loss=lib_tflow.loss, optimizer=lib_tflow.opt, metrics=['accuracy']) self.model = model Model = FinalDense() if args.nodes > 1: distribute(strategy, Model, args.nodes) else: Model.create() dataset = give(1, args.numf, 1, out_size=args.units) dataset = dataset.batch(args.batch) if args.nodes > 1: dataset = strategy.experimental_distribute_dataset(dataset) steps = ds_size // args.batch // args.nodes the_typs = ['_FusedMatMul', 'MatMul'] the_ops = ['FINAL_DENSE'] time = lib_tflow.profile(the_typs, the_ops, Model.model, dataset, steps, args.epochs) import numpy as np
model.add(Dense(units=args.units)) model.add(Flatten(name='FLATTEN')) model.add(Dense(units=10, name='FINAL_DENSE')) model.compile(loss=lib_tflow.loss, optimizer=lib_tflow.opt, metrics=['accuracy']) self.model = model Model = MyDense() if args.nodes > 1: distribute(strategy, Model, args.nodes) else: Model.create() dataset = give(1, args.numf, 1) dataset = dataset.batch(args.batch) if args.nodes > 1: dataset = strategy.experimental_distribute_dataset(dataset) steps = ds_size // args.batch // args.nodes the_typs = ['MatMul'] the_ops = ['dense'] time = lib_tflow.profile(the_typs, the_ops, Model.model, dataset, steps, args.epochs) import numpy as np