File size: 1,380 Bytes
728a6ed
5bd77b5
 
5da936b
7f1aca2
 
 
feb90ac
 
 
 
 
 
 
12bcda5
feb90ac
 
 
 
 
 
 
 
 
 
 
 
7d34933
5da936b
7d34933
 
 
 
 
 
9def5da
654a34d
9def5da
7f1aca2
1af0f6e
7f1aca2
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# https://github.com/google-research/tensorflow-coder/blob/master/tf_coder/tf_coder_main.py
import streamlit as st
from tf_coder.value_search import colab_interface
from tf_coder.value_search import value_search_settings
import io
from contextlib import redirect_stdout

def get_problem():
  """Specifies a problem to run TF-Coder on. Edit this function!"""
  # A dict mapping input variable names to input tensors.
  inputs = {
      'rows': [10, 20, 30],
      'cols': [1, 2, 3, 4],
  }

  # The single desired output tensor.
  output = [[11, 12, 13, 14],
            [21, 22, 23, 24],
            [31, 32, 33, 34]]

  # A list of relevant scalar constants (if any).
  constants = []

  # An English description of the tensor manipulation.
  description = 'add two vectors with broadcasting to get a matrix'

  return inputs, output, constants, description

settings = value_search_settings.from_dict({
      'timeout': 300,
      'only_minimal_solutions': False,
      'max_solutions': 1,
      'require_all_inputs_used': True,
      'require_one_input_used': False,
  })

i = st.text_area("input tensor","second test")

with io.StringIO() as buf, redirect_stdout(buf):
    inputs, output, constants, description = get_problem()
    colab_interface.run_value_search_from_colab(inputs, output, constants, description, settings)
    output = buf.getvalue()
st.write(output)