google / model_search

Apache License 2.0
3.26k stars 462 forks source link

KeyError: 0 #37

Closed RygarNelson closed 3 years ago

RygarNelson commented 3 years ago

I'm trying to run the example provided by the tool in the README file. After many fixed error, I have found this one and I have no solution.

The error

Traceback (most recent call last):
  File "d:/Tesi_Magistrale/google_model_search/test.py", line 14, in <module>
    trainer.try_models(
  File "d:\Tesi_Magistrale\google_model_search\model_search\single_trainer.py", line 56, in try_models
    phoenix_instance = phoenix.Phoenix(
  File "d:\Tesi_Magistrale\google_model_search\model_search\phoenix.py", line 244, in __init__
    self._controller = controller.InProcessController(
  File "d:\Tesi_Magistrale\google_model_search\model_search\controller.py", line 147, in __init__
    self._search_candidate_generator = SearchCandidateGenerator(
  File "d:\Tesi_Magistrale\google_model_search\model_search\generators\search_candidate_generator.py", line 57, in __init__
    self._search_algorithm = search_algorithms[phoenix_spec.search_type]
KeyError: 0

The code I'm running

import model_search
from model_search import constants
from model_search import single_trainer
from model_search.data import csv_data

trainer = single_trainer.SingleTrainer(
    data=csv_data.Provider(
    label_index=0,
    logits_dimension=2,
    record_defaults=[0, 0, 0, 0],
    filename="model_search/data/testdata/csv_random_data.csv"),
    spec=constants.DEFAULT_DNN)

trainer.try_models(
    number_models=200,
    train_steps=1000,
    eval_steps=100,
    root_dir="/tmp/run_example",
    batch_size=32,
    experiment_name="example",
    experiment_owner="model_search_user")

I have no idea on what I need to check for the resolution.

praneethkv commented 3 years ago

import sys from absl import app

Addresses UnrecognizedFlagError: Unknown command line flag 'f'

sys.argv = sys.argv[:1]

app.runcallssys.exit`

try: app.run(lambda argv: None) except: pass

Paste the above code after you import packages and before initializing the trainer, and also change the spec to "model_search/configs/dnn_config.pbtxt"

This should work PS: Do the indentation part with try and except as indents are not allowed in text comment

RygarNelson commented 3 years ago

Thank you very much. The problem has been solved.