当前位置: 首页>>代码示例>>Python>>正文


Python hparam.parse_values函数代码示例

本文整理汇总了Python中tensorflow.contrib.training.python.training.hparam.parse_values函数的典型用法代码示例。如果您正苦于以下问题:Python parse_values函数的具体用法?Python parse_values怎么用?Python parse_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_values函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testParseValuesWithIndexAssigment2_IgnoreUnknown

 def testParseValuesWithIndexAssigment2_IgnoreUnknown(self):
   """Assignment to multiple index positions."""
   parse_dict = hparam.parse_values(
       'arr[0]=10,arr[5]=20,foo=bar', {'arr': int}, ignore_unknown=True)
   self.assertEqual(len(parse_dict), 1)
   self.assertTrue(isinstance(parse_dict['arr'], dict))
   self.assertDictEqual(parse_dict['arr'], {0: 10, 5: 20})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:7,代码来源:hparam_test.py

示例2: testParseValuesWithIndexAssigment1_IgnoreUnknown

 def testParseValuesWithIndexAssigment1_IgnoreUnknown(self):
   """Assignment to an index position."""
   parse_dict = hparam.parse_values(
       'arr[1]=10,b=5', {'arr': int}, ignore_unknown=True)
   self.assertEqual(len(parse_dict), 1)
   self.assertTrue(isinstance(parse_dict['arr'], dict))
   self.assertDictEqual(parse_dict['arr'], {1: 10})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:7,代码来源:hparam_test.py

示例3: testParseValuesWithIndexAssigment3

 def testParseValuesWithIndexAssigment3(self):
   """Assignment to index positions in multiple names."""
   parse_dict = hparam.parse_values('arr[0]=10,arr[1]=20,L[5]=100,L[10]=200',
                                    {'arr': int,
                                     'L': int})
   self.assertEqual(len(parse_dict), 2)
   self.assertTrue(isinstance(parse_dict['arr'], dict))
   self.assertDictEqual(parse_dict['arr'], {0: 10, 1: 20})
   self.assertTrue(isinstance(parse_dict['L'], dict))
   self.assertDictEqual(parse_dict['L'], {5: 100, 10: 200})
开发者ID:DjangoPeng,项目名称:tensorflow,代码行数:10,代码来源:hparam_test.py

示例4: testParseValuesWithIndexAssigment4_IgnoreUnknown

 def testParseValuesWithIndexAssigment4_IgnoreUnknown(self):
   """Assignment of index positions and scalars."""
   parse_dict = hparam.parse_values(
       'x=10,foo[0]=bar,arr[1]=20,zzz=78,y=30',
       {'x': int, 'y': int, 'arr': int}, ignore_unknown=True)
   self.assertEqual(len(parse_dict), 3)
   self.assertTrue(isinstance(parse_dict['arr'], dict))
   self.assertDictEqual(parse_dict['arr'], {1: 20})
   self.assertEqual(parse_dict['x'], 10)
   self.assertEqual(parse_dict['y'], 30)
开发者ID:perfmjs,项目名称:tensorflow,代码行数:10,代码来源:hparam_test.py

示例5: testParseValuesWithIndexAssigment4

 def testParseValuesWithIndexAssigment4(self):
   """Assignment of index positions and scalars."""
   parse_dict = hparam.parse_values('x=10,arr[1]=20,y=30',
                                    {'x': int,
                                     'y': int,
                                     'arr': int})
   self.assertEqual(len(parse_dict), 3)
   self.assertTrue(isinstance(parse_dict['arr'], dict))
   self.assertDictEqual(parse_dict['arr'], {1: 20})
   self.assertEqual(parse_dict['x'], 10)
   self.assertEqual(parse_dict['y'], 30)
开发者ID:DjangoPeng,项目名称:tensorflow,代码行数:11,代码来源:hparam_test.py

示例6: testWithReusedVariables

  def testWithReusedVariables(self):
    with self.assertRaisesRegexp(ValueError,
                                 'Multiple assignments to variable \'x\''):
      hparam.parse_values('x=1,x=1', {'x': int})

    with self.assertRaisesRegexp(ValueError,
                                 'Multiple assignments to variable \'arr\''):
      hparam.parse_values('arr=[100,200],arr[0]=10', {'arr': int})

    with self.assertRaisesRegexp(
        ValueError, r'Multiple assignments to variable \'arr\[0\]\''):
      hparam.parse_values('arr[0]=10,arr[0]=20', {'arr': int})

    with self.assertRaisesRegexp(ValueError,
                                 'Multiple assignments to variable \'arr\''):
      hparam.parse_values('arr[0]=10,arr=[100]', {'arr': int})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:16,代码来源:hparam_test.py

示例7: testParseValuesWithIndexAssigment5_IgnoreUnknown

 def testParseValuesWithIndexAssigment5_IgnoreUnknown(self):
   """Different variable types."""
   parse_dict = hparam.parse_values(
       'a[0]=5,cc=4,b[1]=true,c[2]=abc,mm=2,d[3]=3.14',
       {'a': int, 'b': bool, 'c': str, 'd': float},
       ignore_unknown=True)
   self.assertEqual(set(parse_dict.keys()), {'a', 'b', 'c', 'd'})
   self.assertTrue(isinstance(parse_dict['a'], dict))
   self.assertDictEqual(parse_dict['a'], {0: 5})
   self.assertTrue(isinstance(parse_dict['b'], dict))
   self.assertDictEqual(parse_dict['b'], {1: True})
   self.assertTrue(isinstance(parse_dict['c'], dict))
   self.assertDictEqual(parse_dict['c'], {2: 'abc'})
   self.assertTrue(isinstance(parse_dict['d'], dict))
   self.assertDictEqual(parse_dict['d'], {3: 3.14})
开发者ID:perfmjs,项目名称:tensorflow,代码行数:15,代码来源:hparam_test.py

示例8: testParseValuesWithBadIndexAssigment3_IgnoreUnknown

 def testParseValuesWithBadIndexAssigment3_IgnoreUnknown(self):
   """Ignore type of the form name[index]."""
   hparam.parse_values('arr[1]=1', {'arr[1]': int}, ignore_unknown=True)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:3,代码来源:hparam_test.py

示例9: testParseValuesWithBadIndexAssigment3

 def testParseValuesWithBadIndexAssigment3(self):
   """Reject type of the form name[index]."""
   with self.assertRaisesRegexp(ValueError,
                                'Unknown hyperparameter type for arr'):
     hparam.parse_values('arr[1]=1', {'arr[1]': int})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:5,代码来源:hparam_test.py

示例10: testParseValuesWithBadIndexAssigment2_IgnoreUnknown

 def testParseValuesWithBadIndexAssigment2_IgnoreUnknown(self):
   """Ignore missing type."""
   hparam.parse_values('arr[1]=5', {}, ignore_unknown=True)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:3,代码来源:hparam_test.py

示例11: testParseValuesWithBadIndexAssigment2

 def testParseValuesWithBadIndexAssigment2(self):
   """Reject if type missing."""
   with self.assertRaisesRegexp(ValueError,
                                r'Unknown hyperparameter type for arr'):
     hparam.parse_values('arr[1]=5', {})
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:5,代码来源:hparam_test.py

示例12: testParseValuesWithBadIndexAssigment1_IgnoreUnknown

 def testParseValuesWithBadIndexAssigment1_IgnoreUnknown(self):
   """Reject assignment of list to variable type."""
   with self.assertRaisesRegexp(ValueError,
                                r'Assignment of a list to a list index.'):
     hparam.parse_values(
         'arr[1]=[1,2,3],c=8', {'arr': int}, ignore_unknown=True)
开发者ID:adit-chandra,项目名称:tensorflow,代码行数:6,代码来源:hparam_test.py


注:本文中的tensorflow.contrib.training.python.training.hparam.parse_values函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。