You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

paddle_backend.py 22 kB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  1. #! /usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import absolute_import, division, print_function
  4. import paddle as pd
  5. import paddle.nn as nn
  6. _dtypeDict = ["float16", "float32", "float64", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"]
  7. # TODO NotImplemented
  8. DType = None
  9. float16 = "float16"
  10. float32 = "float32"
  11. float64 = "float64"
  12. int8 = "int8"
  13. int16 = "int16"
  14. int32 = "int32"
  15. int64 = "int64"
  16. uint8 = "uint8"
  17. uint16 = "uint16"
  18. uint32 = "uint32"
  19. uint64 = "uint64"
  20. def _getter(init_fn, **kwargs):
  21. """Return an named eager tensor."""
  22. raise NotImplementedError
  23. def set_context(**kwargs):
  24. raise Exception("Using Paddle backend,You don't need to set context")
  25. def get_tensor_shape(x):
  26. return pd.shape(x)
  27. # initializers
  28. def zeros(shape, dtype="float32"):
  29. """
  30. Creates a tensor with all elements set to zero.
  31. Parameters
  32. ----------
  33. shape : A list of integers
  34. a tuple of integers, or a 1-D Tensor of type int32.
  35. dtype : tensor
  36. The DType of an element in the resulting Tensor
  37. Returns
  38. -------
  39. A Tensor with all elements set to zero.
  40. """
  41. return pd.zeros(shape=shape, dtype=dtype)
  42. def ones(shape, dtype="float32"):
  43. """
  44. Creates a tensor with all elements set to ones.
  45. Parameters
  46. ----------
  47. shape : A list of integers
  48. a tuple of integers, or a 1-D Tensor of type int32.
  49. dtype : tensor
  50. The DType of an element in the resulting Tensor
  51. Returns
  52. -------
  53. A Tensor with all elements set to zero.
  54. """
  55. return pd.ones(shape=shape, dtype=dtype)
  56. def constant(value, shape, dtype="float32"):
  57. """
  58. Creates a constant tensor from a tensor-like object.
  59. Parameters
  60. ----------
  61. value : list
  62. A constant value (or list) of output type dtype.
  63. dtype : tensor
  64. The type of the elements of the resulting tensor.
  65. shape : tuple
  66. Optional dimensions of resulting tensor.
  67. Returns
  68. -------
  69. A Constant Tensor.
  70. """
  71. return nn.initializer.constant(value=value)
  72. def random_uniform(shape, minval=0, maxval=None, dtype="float32", seed=None):
  73. """
  74. Outputs random values from a uniform distribution.
  75. Parameters
  76. ----------
  77. shape : tuple
  78. A 1-D integer Tensor or Python array. The shape of the output tensor.
  79. minval : int
  80. The lower bound on the range of random values to generate (inclusive). Defaults to 0.
  81. maxval : int
  82. The upper bound on the range of random values to generate (exclusive). Defaults to 1 if dtype is floating point.
  83. dtype : tensor
  84. The type of the output: float16, float32, float64, int32, or int64.
  85. seed : int
  86. Used in combination with dragon.random.set_seed to create a reproducible sequence of tensors across multiple calls.
  87. Returns
  88. -------
  89. A tensor of the specified shape filled with random uniform values.
  90. """
  91. raise NotImplementedError
  92. def random_normal(shape, mean=0.0, stddev=1.0, dtype="float32", seed=None):
  93. """
  94. Outputs random values from a normal distribution.
  95. Parameters
  96. ----------
  97. shape : tuple
  98. A 1-D integer Tensor or Python array. The shape of the output tensor.
  99. mean : float
  100. The mean of the normal distribution
  101. stddev : float
  102. The standard deviation of the normal distribution.
  103. dtype : tensor
  104. The type of the output.
  105. seed : A Python integer
  106. Used to create a random seed for the distribution
  107. Returns
  108. -------
  109. A tensor of the specified shape filled with random normal values.
  110. """
  111. raise NotImplementedError
  112. def truncated_normal(shape, mean=0.0, stddev=1.0, dtype="float32", seed=None):
  113. """
  114. Outputs random values from a truncated normal distribution.
  115. Parameters
  116. ----------
  117. shape : tuple
  118. A 1-D integer Tensor or Python array. The shape of the output tensor.
  119. mean : float
  120. The mean of the normal distribution
  121. stddev : float
  122. The standard deviation of the normal distribution.
  123. dtype : tensor
  124. The type of the output.
  125. seed : A Python integer
  126. Used to create a random seed for the distribution
  127. Returns
  128. -------
  129. A tensor of the specified shape filled with random truncated normal values.
  130. """
  131. raise NotImplementedError
  132. def he_normal(shape, dtype, seed=None):
  133. """
  134. He normal initializer.
  135. Parameters
  136. ----------
  137. seed : A Python integer.
  138. Used to seed the random generator.
  139. shape : tuple
  140. A 1-D integer Tensor or Python array. The shape of the output tensor.
  141. dtype : tensor
  142. The type of the output.
  143. Returns
  144. -------
  145. A tensor of the specified shape filled with he normal values.
  146. """
  147. # shape = shape[::-1]
  148. raise NotImplementedError
  149. def Variable(initial_value, name, trainable=None):
  150. """
  151. Creates a new variable with value initial_value.
  152. Parameters
  153. ----------
  154. initial_value : tensor
  155. A Tensor, or Python object convertible to a Tensor
  156. name : str
  157. Optional name for the variable. Defaults to 'Variable' and gets uniquified automatically.
  158. Returns
  159. -------
  160. Variable
  161. """
  162. raise NotImplementedError
  163. class MatMul(object):
  164. def __init__(self):
  165. pass
  166. def __call__(self, a, b):
  167. return pd.matmul(x=a, y=b)
  168. def matmul(a, b):
  169. """
  170. Multiplies matrix a by matrix b, producing a * b.
  171. Parameters
  172. ----------
  173. a : tensor
  174. type float16, float32, float64, int32, complex64, complex128 and rank > 1.
  175. b : tensor
  176. with same type and rank as a.
  177. Returns
  178. -------
  179. A Tensor of the same type as a and b
  180. """
  181. raise NotImplementedError
  182. def add(value, bias):
  183. """
  184. Returns x + y element-wise.
  185. Parameters
  186. ----------
  187. value : tensor.
  188. Must be one of the following types: bfloat16, half, float32, float64,
  189. uint8, int8, int16, int32, int64, complex64, complex128, string.
  190. bias : tensor
  191. Must have the same type as a
  192. name : str
  193. A name for the operation
  194. Returns
  195. -------
  196. A Tensor. Has the same type as a.
  197. """
  198. raise NotImplementedError
  199. def dtypes(dt):
  200. """
  201. Data dtypes.
  202. Parameters
  203. ----------
  204. dt : string
  205. It could be 'uint8', 'uint16', 'uint32', 'uint64', 'int8', 'int16',
  206. 'int32', 'int64', 'float16', 'float32', 'float64', 'DType'.
  207. Returns
  208. -------
  209. Data dtypes
  210. """
  211. raise NotImplementedError
  212. class Maximum(object):
  213. def __init__(self):
  214. pass
  215. def __call__(self, x, y):
  216. raise NotImplementedError
  217. class Minimum(object):
  218. def __init__(self):
  219. pass
  220. def __call__(self, x, y):
  221. raise NotImplementedError
  222. def minimum(x, y):
  223. """
  224. Returns the min of x and y (i.e. x < y ? x : y) element-wise.
  225. Parameters
  226. ----------
  227. x : tensor.
  228. Must be one of the following types: bfloat16, half, float32, float64, int32, int64.
  229. y : A Tensor.
  230. Must have the same type as x.
  231. name : str
  232. A name for the operation (optional).
  233. Returns
  234. -------
  235. A Tensor. Has the same type as x
  236. """
  237. raise NotImplementedError
  238. class FlattenReshape(object):
  239. def __init__(self):
  240. pass
  241. def __call__(self, inputs):
  242. return pd.flatten(x=inputs, start_axis=1, stop_axis=-1)
  243. class Reshape(object):
  244. def __init__(self, shape):
  245. self.shape = shape
  246. def __call__(self, tensor):
  247. raise NotImplementedError
  248. def reshape(tensor, shape):
  249. """
  250. Reshapes a tensor.
  251. Parameters
  252. ----------
  253. tensor : tensor
  254. A Tensor.
  255. shape : tensor
  256. Defines the shape of the output tensor.
  257. Returns
  258. -------
  259. A Tensor. Has the same type as tensor
  260. """
  261. return pd.reshape(tensor, shape)
  262. class Concat(object):
  263. def __init__(self, axis):
  264. super(Concat, self).__init__()
  265. self.axis = axis
  266. def __call__(self, values):
  267. raise NotImplementedError
  268. def concat(values, axis):
  269. """
  270. Concatenates tensors along one dimension.
  271. Parameters
  272. ----------
  273. values : list
  274. A list of Tensor objects or a single Tensor
  275. axis : int
  276. 0-D int32 Tensor. Dimension along which to concatenate
  277. Returns
  278. -------
  279. A Tensor resulting from concatenation of the input tensors.
  280. """
  281. raise NotImplementedError
  282. def convert_to_tensor(value, dtype=float32):
  283. """
  284. Converts the given value to a Tensor.
  285. Parameters
  286. ----------
  287. value : object
  288. An object whose type has a registered Tensor conversion function.
  289. dtype : optional
  290. Optional element type for the returned tensor. If missing, the type is inferred from the type of value.
  291. Returns
  292. -------
  293. A Tensor based on value.
  294. """
  295. return pd.to_tensor(value, dtype=dtype)
  296. def convert_to_numpy(value):
  297. return value.numpy()
  298. def sqrt(x):
  299. """
  300. Computes square root of x element-wise.
  301. Parameters
  302. ----------
  303. x : tensor
  304. Must be one of the following types: bfloat16, half, float32, float64, complex64, complex128.
  305. Returns
  306. -------
  307. A Tensor. Has the same type as x.
  308. """
  309. raise NotImplementedError
  310. class ReduceSum(object):
  311. def __init__(self, axis):
  312. pass
  313. def construct(self, input):
  314. pass
  315. class ReduceMean(object):
  316. def __init__(self, axis):
  317. self.axis = axis
  318. def __call__(self, inputs):
  319. return pd.mean(inputs, axis=self.axis)
  320. def reduce_mean(input_tensor, axis=None):
  321. """
  322. Computes the mean of elements across dimensions of a tensor.
  323. Parameters
  324. ----------
  325. input_tensor : tensor
  326. The tensor to reduce. Should have numeric type.
  327. axis : int
  328. The dimensions to reduce. If None (the default), reduces all dimensions.
  329. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  330. name : str
  331. A name for the operation (optional).
  332. Returns
  333. -------
  334. The reduced tensor.
  335. """
  336. raise NotImplementedError
  337. class ReduceMax(object):
  338. def __init__(self, axis):
  339. self.axis = axis
  340. def __call__(self, inputs):
  341. return pd.max(inputs, axis=self.axis)
  342. def reduce_max(input_tensor, axis=None):
  343. """
  344. Computes the maximum of elements across dimensions of a tensor.
  345. Parameters
  346. ----------
  347. input_tensor : tensor
  348. The tensor to reduce. Should have real numeric type.
  349. axis : int
  350. The dimensions to reduce. If None (the default), reduces all dimensions.
  351. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  352. name : str
  353. A name for the operation (optional).
  354. Returns
  355. -------
  356. The reduced tensor.
  357. """
  358. raise NotImplementedError
  359. def reduce_min(input_tensor, axis=None):
  360. """
  361. Computes the minimum of elements across dimensions of a tensor.
  362. Parameters
  363. ----------
  364. input_tensor : tensor
  365. The tensor to reduce. Should have real numeric type.
  366. axis : int
  367. The dimensions to reduce. If None (the default), reduces all dimensions.
  368. Must be in the range [-rank(input_tensor), rank(input_tensor)).
  369. name : str
  370. A name for the operation (optional).
  371. Returns
  372. -------
  373. The reduced tensor.
  374. """
  375. raise NotImplementedError
  376. class Pad(object):
  377. def __init__(self, paddings, mode="REFLECT"):
  378. if mode not in ['CONSTANT', 'REFLECT', 'SYMMETRIC']:
  379. raise Exception("Unsupported mode: {}".format(mode))
  380. if mode == 'SYMMETRIC':
  381. mode = 'EDGE'
  382. self.paddings = paddings
  383. self.mode = mode
  384. def __call__(self, x):
  385. raise NotImplementedError
  386. def pad(tensor, paddings, mode='CONSTANT', constant_values=0):
  387. """
  388. Pads a tensor.
  389. Parameters
  390. ----------
  391. tensor : tensor
  392. A Tensor.
  393. paddings : tuple
  394. A tuple of type int32.
  395. mode : str
  396. One of "CONSTANT", "REFLECT", or "SYMMETRIC" (case-insensitive)
  397. constant_values : int
  398. In "CONSTANT" mode, the scalar pad value to use. Must be same type as tensor.
  399. Returns
  400. -------
  401. A Tensor. Has the same type as tensor.
  402. """
  403. raise NotImplementedError
  404. class Unstack(object):
  405. def __init__(self, axis, num=None):
  406. self.axis = axis
  407. self.num = num
  408. def __call__(self, values):
  409. raise NotImplementedError
  410. class Stack(object):
  411. def __init__(self, axis):
  412. self.axis = axis
  413. def __call__(self, values):
  414. raise NotImplementedError
  415. def stack(values, axis=0):
  416. """
  417. Stacks a list of rank-R tensors into one rank-(R+1) tensor.
  418. Parameters
  419. ----------
  420. values : list
  421. A list of Tensor objects with the same shape and type.
  422. axis : int
  423. An int. The axis to stack along. Defaults to the first dimension.
  424. Negative values wrap around, so the valid range is [-(R+1), R+1).
  425. Returns
  426. -------
  427. A stacked Tensor with the same type as values.
  428. """
  429. raise NotImplementedError
  430. class Meshgrid(object):
  431. def __init__(self, indexing='xy'):
  432. super(Meshgrid, self).__init__()
  433. self.index = indexing
  434. def __call__(self, inputs):
  435. pass
  436. def meshgrid(x, y):
  437. """
  438. Broadcasts parameters for evaluation on an N-D grid.
  439. Parameters
  440. ----------
  441. x : tensor
  442. Tensors with rank 1.
  443. y : tensor
  444. Tensors with rank 1.
  445. Returns
  446. -------
  447. A list of N Tensors with rank N.
  448. """
  449. pass
  450. def range(start, limit=None, delta=1, dtype=None):
  451. """
  452. Creates a sequence of numbers.
  453. Parameters
  454. ----------
  455. start : tensor
  456. A 0-D Tensor (scalar). Acts as first entry in the range if limit is not None;
  457. otherwise, acts as range limit and first entry defaults to 0.
  458. limit : tensor
  459. A 0-D Tensor (scalar). Upper limit of sequence, exclusive. If None,
  460. defaults to the value of start while the first entry of the range defaults to 0.
  461. delta : tensor
  462. A 0-D Tensor (scalar). Number that increments start. Defaults to 1.
  463. dtype : type
  464. The type of the elements of the resulting tensor.
  465. Returns
  466. -------
  467. An 1-D Tensor of type dtype.
  468. """
  469. raise NotImplementedError
  470. class ExpandDims(object):
  471. def __init__(self, axis):
  472. pass
  473. def construct(self, input):
  474. pass
  475. def expand_dims(input, axis):
  476. """
  477. Inserts a dimension of 1 into a tensor's shape.
  478. Parameters
  479. ----------
  480. input : tensor
  481. A Tensor.
  482. axis : int
  483. 0-D (scalar). Specifies the dimension index at which to expand the shape of input.
  484. Must be in the range [-rank(input) - 1, rank(input)].
  485. Returns
  486. -------
  487. A Tensor with the same data as input, but its shape has an additional dimension of size 1 added.
  488. """
  489. raise NotImplementedError
  490. class Tile(object):
  491. def __init__(self):
  492. pass
  493. def __call__(self, input, multiples):
  494. raise NotImplementedError
  495. def tile(input, multiples):
  496. """
  497. Constructs a tensor by tiling a given tensor.
  498. Parameters
  499. ----------
  500. input : tensor
  501. A Tensor. 1-D or higher.
  502. multiples : tensor
  503. Must be one of the following types: int32, int64. 1-D.
  504. Length must be the same as the number of dimensions in input
  505. Returns
  506. -------
  507. A Tensor. Has the same type as input.
  508. """
  509. raise NotImplementedError
  510. class Cast(object):
  511. def __init__(self, dtype):
  512. pass
  513. def __call__(self, input):
  514. pass
  515. def cast(x, dtype):
  516. """
  517. Casts a tensor to a new type.
  518. Parameters
  519. ----------
  520. x : tensor
  521. A Tensor or SparseTensor or IndexedSlices of numeric type.
  522. It could be uint8, uint16, uint32, uint64, int8, int16, int32, int64, float16, float32, float64.
  523. dtype : dtpye
  524. The destination type. The list of supported dtypes is the same as x
  525. Returns
  526. -------
  527. A Tensor or SparseTensor or IndexedSlices with same shape as x and same type as dtype.
  528. """
  529. raise NotImplementedError
  530. class Transpose(object):
  531. def __init__(self, perm, conjugate=False):
  532. self.perm = perm
  533. if conjugate:
  534. raise ("The conjugate Parameters not supported")
  535. def __call__(self, a):
  536. raise NotImplementedError
  537. def transpose(a, perm=None, conjugate=False):
  538. """
  539. Transposes a.
  540. Parameters
  541. ----------
  542. a : tensor
  543. A Tensor.
  544. perm : int
  545. A permutation of the dimensions of a.
  546. conjugate : bool
  547. Setting it to True is mathematically equivalent to ms.math.conj(ms.transpose(input)).
  548. Returns
  549. -------
  550. A transposed Tensor.
  551. """
  552. raise NotImplementedError
  553. def gather_nd(params, indices, batch_dims=0):
  554. """
  555. Gather slices from params into a Tensor with shape specified by indices.
  556. Parameters
  557. ----------
  558. params : tensor
  559. The tensor from which to gather values.
  560. indices : tensor
  561. Must be one of the following types: int32, int64. Index tensor.
  562. batch_dims : int
  563. An integer or a scalar 'Tensor'. The number of batch dimensions.
  564. Returns
  565. -------
  566. A Tensor. Has the same type as params.
  567. """
  568. pass
  569. def clip_by_value(t, clip_value_min, clip_value_max):
  570. """
  571. Clips tensor values to a specified min and max.
  572. Parameters
  573. ----------
  574. t : tensor
  575. A Tensor or IndexedSlices
  576. clip_value_min : tensor
  577. A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The minimum value to clip by
  578. clip_value_max : tensor
  579. A 0-D (scalar) Tensor, or a Tensor with the same shape as t. The minimum value to clip by
  580. Returns
  581. -------
  582. A clipped Tensor or IndexedSlices.
  583. """
  584. pass
  585. def split(value, num_or_size_splits, axis=0, num=None):
  586. """
  587. Splits a tensor into sub tensors.
  588. Parameters
  589. ----------
  590. value : tensor
  591. The Tensor to split.
  592. num_or_size_splits : list
  593. Either an integer indicating the number of splits along split_dim or a 1-D integer Tensor or
  594. Python list containing the sizes of each output tensor along split_dim.
  595. axis : int
  596. The dimension along which to split. Must be in the range [-rank(value), rank(value)). Defaults to 0.
  597. num : int
  598. used to specify the number of outputs when it cannot be inferred from the shape of size_splits.
  599. Returns
  600. -------
  601. Tensor objects resulting from splitting value.
  602. """
  603. pass
  604. class Floor(object):
  605. def __call__(self, *args, **kwargs):
  606. raise NotImplementedError
  607. def floor(x):
  608. raise NotImplementedError
  609. def gather(params, indices):
  610. raise NotImplementedError
  611. def linspace(start, stop, num):
  612. raise NotImplementedError
  613. def slice(inputs, starts, sizes):
  614. raise NotImplementedError
  615. def add_n(inputs):
  616. raise NotImplementedError
  617. class OneHot(object):
  618. def __init__(self, axis=-1, depth=1, on_value=1.0, off_value=0.0, dtype="float32"):
  619. self.depth = depth
  620. self.dtype = dtype
  621. def __call__(self, indices):
  622. raise NotImplementedError
  623. class L2Normalize(object):
  624. def __init__(self, axis=None, epsilon=1e-12):
  625. super(L2Normalize, self).__init__()
  626. pass
  627. def __call__(self, input, *args, **kwargs):
  628. pass
  629. class EmbeddingLookup(object):
  630. def __init__(self, max_norm=None):
  631. self.max_norm = max_norm
  632. def __call__(self, params, ids, *args, **kwargs):
  633. pass
  634. class NCELoss(object):
  635. def __init__(self, num_true=1, sampled_values=None, remove_accidental_hits=False):
  636. super(NCELoss, self).__init__()
  637. def __call__(self, weights, biases, labels, inputs, num_sampled, num_classes):
  638. pass
  639. class NotEqual(object):
  640. def __init__(self):
  641. pass
  642. def __call__(self, x, y):
  643. pass
  644. class CountNonzero(object):
  645. def __init__(self, keepdims=None, dtype="int64"):
  646. pass
  647. def __call__(self, *args, **kwargs):
  648. pass
  649. class Resize:
  650. def __init__(self, scale, method, antialias=False, data_format='channels_last', ksize=None):
  651. if method not in ['nearest', 'linear', 'bilinear']:
  652. raise ('Current resize does not support this method.')
  653. if method == 'bilinear':
  654. method = 'linear'
  655. self.method = method
  656. self.antialias = antialias
  657. self.scale = scale
  658. if data_format != 'channel_last':
  659. raise Exception("UpSampling2d resize_images only support channel_last")
  660. def __call__(self, inputs):
  661. raise NotImplementedError
  662. def resize(inputs, output_size, method, antialias):
  663. raise NotImplementedError
  664. class ZeroPadding1D(object):
  665. def __init__(self):
  666. pass
  667. def __call__(self, padding):
  668. raise NotImplementedError
  669. class ZeroPadding2D(object):
  670. def __init__(self):
  671. pass
  672. def __call__(self, padding):
  673. raise NotImplementedError
  674. class ZeroPadding3D(object):
  675. def __init__(self):
  676. pass
  677. def __call__(self, padding):
  678. raise NotImplementedError
  679. class Sign(object):
  680. def __init__(self):
  681. pass
  682. def __call__(self, x):
  683. raise NotImplementedError
  684. class Ceil(object):
  685. def __call__(self, *args, **kwargs):
  686. raise NotImplementedError
  687. def ceil(x):
  688. raise NotImplementedError
  689. def multiply(x, y):
  690. raise NotImplementedError
  691. def divide(x, y):
  692. raise NotImplementedError
  693. def identity(x):
  694. raise NotImplementedError
  695. class BatchToSpace(object):
  696. def __init__(self, block_size, crops):
  697. super(BatchToSpace, self).__init__()
  698. pass
  699. def __call__(self, input_x):
  700. raise NotImplementedError
  701. class DepthToSpace(object):
  702. def __init__(self, block_size, data_format='NHWC'):
  703. pass
  704. def __call__(self, input):
  705. raise NotImplementedError

TensorLayer3.0 是一款兼容多种深度学习框架为计算后端的深度学习库。计划兼容TensorFlow, Pytorch, MindSpore, Paddle.