def run( file ) : ssd = ram.Ram( ) cmd = cpu.Cpu( 0, ssd, verbose ) ssd.loader( file ) #testRam( ssd ) #testCpu( ssd ) cmd.run( )
def deitel_version( ) : print ' *** Welcome to Simpletron! ***\n\ *** Please enter your program one instruction ***\n\ *** (or data word) at a time into the input ***\n\ *** text field. I will display the location ***\n\ *** number and a question mark (?). You then ***\n\ *** type the word for that location. Enter the ***\n\ *** hash twice to stop entering your program. ***' ssd = ram.Ram( ) addr = 0 while True : unknown = raw_input( str( addr ) + "_?_" ) if exit( unknown ) : print "Stopping input. Running Simpletron ..." break elif invalid( unknown ) : print "\tinvalid, use {-9999 - 9999}" continue val = int( unknown ) ssd.setAt( addr, val ) addr += 1 cmd = cpu.Cpu( 0, ssd, not verbose ) cmd.run( )
def inicializar_rams(self): numero_rams = int( round(self.tamanho_entrada / self.numero_entradas_rams)) for i in range(0, numero_rams): self.rams.append(ram.Ram(self.numero_entradas_rams))
def __init__( self, tam ): #Construtor da classe SO, parametro de entrada é um objeto da classe Ram self.ram = ram.Ram() self.cpu = cpu.Cpu(self.ram, tam, self.ram.palavras)
import processor import ram import storage import display import keyboard import mouse import computer processor = processor.Processor('3.4 GHz', 2) ram = ram.Ram(500) storage = storage.Storage(5000) display = display.Display('LG', '1920x1080') keyboard = keyboard.Keyboard('Samsung') mouse = mouse.Mouse('Apple') class ComputerBuilder: def build(self): return computer.Computer(processor, ram, storage, display, keyboard, mouse)
# # Name each loss as '(raw)' and name the moving average version of the loss # # as the original loss name. # tf.scalar_summary(loss_name +' (raw)', l) # tf.scalar_summary(loss_name, loss_averages.average(l)) #with tf.control_dependencies([loss_averages_op]): # total_loss = tf.identity(total_loss) #return total_loss, grads debug = labels return loss, grads, debug def evaluate(self): feed_dict = self.reader.next_train() x = feed_dict['images'] labels = feed_dict['labels'] # Build inference Graph. loc_mean_t, loc_t, h_t, prob, pred, debug = self.model.inference(x) correct = tf.nn.in_top_k(prob, labels, 1) return tf.reduce_sum(tf.cast(correct, tf.int32)) reader = reader.Reader('./utils/reader/read_img/translated_mnist_output/', [40, 40, 3], batch_size=16) model = ram.Ram() trainer = Trainer(model, reader, gpus=[0], max_steps=500000, truncation=False) trainer.train()