{"id":19696040,"url":"https://github.com/delsner/tf-apis","last_synced_at":"2025-09-11T00:46:26.187Z","repository":{"id":128465666,"uuid":"167405381","full_name":"delsner/tf-apis","owner":"delsner","description":"Sample scripts to demonstrate use of tf APIs","archived":false,"fork":false,"pushed_at":"2019-01-28T19:40:39.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-07T19:53:59.310Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/delsner.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-01-24T17:09:22.000Z","updated_at":"2019-09-05T15:41:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"a7db854b-6aa5-4678-9611-470c48292198","html_url":"https://github.com/delsner/tf-apis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/delsner/tf-apis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delsner%2Ftf-apis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delsner%2Ftf-apis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delsner%2Ftf-apis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delsner%2Ftf-apis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delsner","download_url":"https://codeload.github.com/delsner/tf-apis/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delsner%2Ftf-apis/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274556378,"owners_count":25307506,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-10T02:00:12.551Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T19:33:14.373Z","updated_at":"2025-09-11T00:46:26.159Z","avatar_url":"https://github.com/delsner.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tf-apis\nSample scripts to demonstrate use of tf APIs\n\n## TF-Estimator API\n\n### Structure of a pre-made Estimators program\n\n#### Write one or more dataset importing functions\n\n```python\ndef input_fn(dataset):\n    \"\"\"\n    feature_dict = keys are feature names and values are tensors\n    label = a tensor containing one or more labels\n    \"\"\"\n    ... # manipulate dataset, extracting the feature dict and the label\n    return feature_dict, label\n```\n\n#### Define the feature columns\n```python\n# Define three numeric feature columns.\npopulation = tf.feature_column.numeric_column('population')\ncrime_rate = tf.feature_column.numeric_column('crime_rate')\nmedian_education = tf.feature_column.numeric_column('median_education',\n                    normalizer_fn=lambda x: x - global_education_mean)\n```\n\n#### Instantiate the relevant pre-made estimator\n```python\n# Instantiate an estimator, passing the feature columns.\nestimator = tf.estimator.LinearClassifier(\n    feature_columns=[population, crime_rate, median_education],\n    )\n```\n\n#### Call a training, evaluation, or inference method\n\n```python\n# my_training_set is the function created in Step 1\nestimator.train(input_fn=my_training_set, steps=2000)\n```\n\n#### Creating Estimators from Keras models\n\n```python\n# Instantiate a Keras inception v3 model.\nkeras_model = tf.keras.applications.inception_v3.InceptionV3(weights=None)\n# Compile model with the optimizer, loss, and metrics you'd like to train with.\nkeras_model.compile(optimizer=tf.keras.optimizers.SGD(lr=0.0001, momentum=0.9),\n                          loss='categorical_crossentropy',\n                          metric='accuracy')\n# Create an Estimator from the compiled Keras model. Note the initial model\n# state of the keras model is preserved in the created Estimator.\nest_model = tf.keras.estimator.model_to_estimator(keras_model=keras_model)\n\n# Treat the derived Estimator as you would with any other Estimator.\n# First, recover the input name(s) of Keras model, so we can use them as the\n# feature column name(s) of the Estimator input function:\nkeras_model.input_names  # print out: ['input_1']\n# Once we have the input name(s), we can create the input function, for example,\n# for input(s) in the format of numpy ndarray:\ntrain_input_fn = tf.estimator.inputs.numpy_input_fn(\n    x={\"input_1\": train_data},\n    y=train_labels,\n    num_epochs=1,\n    shuffle=False)\n# To train, we call Estimator's train function:\nest_model.train(input_fn=train_input_fn, steps=2000)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelsner%2Ftf-apis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelsner%2Ftf-apis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelsner%2Ftf-apis/lists"}